Problem Statement
Given are N strings S1,ldots,SN, each of which is AND
or OR
.
Find the number of tuples of N+1 variables (x0,ldots,xN), where each element is textTrue or textFalse, such that the following computation results in yN being textTrue:
- y0=x0;
- for igeq1, yi=yi−1landxi if Si is
AND
, and yi=yi−1lorxi if Si is OR
.
Here, alandb and alorb are logical operators.
Constraints
- 1leqNleq60
- Si is
AND
or OR
.
Input is given from Standard Input in the following format:
N
S1
vdots
SN
Output
Print the answer.
2
AND
OR
Sample Output 1
5
For example, if $(x_0,x_1,x_2)=(\\text{True},\\text{False},\\text{True})$, we have y2=textTrue, as follows:
- y0=x0=textTrue
- $y_1=y_0 \\land x_1 = \\text{True} \\land \\text{False}=\\text{False}$
- $y_2=y_1 \\lor x_2 = \\text{False} \\lor \\text{True}=\\text{True}$
All of the five tuples (x0,x1,x2) resulting in y2=textTrue are shown below:
- (textTrue,textTrue,textTrue)
- (textTrue,textTrue,textFalse)
- (textTrue,textFalse,textTrue)
- (textFalse,textTrue,textTrue)
- (textFalse,textFalse,textTrue)
5
OR
OR
OR
OR
OR
Sample Output 2
63
All tuples except the one filled entirely with textFalse result in y5=textTrue.