VirtualData has just found two binary set A1,A2,⋯,An and B1,B2,⋯,Bn (Ai,Bi∈{0, 1} for all 1≤i≤n) from his virtual machine! He would like to perform the operation described below exactly twice, so that Ai=Bi holds for all 1≤i≤n after the two operations.
The operation is: Select two integers l and r (1≤l≤r≤n), change Ai to (1−Ai) for all l≤i≤r. VirtualData would like to know the number of ways to do so.
We use the following rules to determine whether two ways are different:
Input format
Output format
Print an integer in a new line, representing the number of unique ways given operation can be performed.
Constraints
1≤n≤106
In this case, we have the following options, (0 based indexing):
So, there are a total of 6 distinct ways to perform the operations and make both sequences identical, hence the output is 6.