题目描述
给定 N 个字符串 S1,ldots,SN,每个字符串是 AND
或 OR
。
找出 N+1 个变量 (x0,ldots,xN) 的元组数量,其中每个元素都是 textTrue 或 textFalse,使得以下计算得出 yN 为 textTrue:
- y0=x0;
- 对于 igeq1,如果 Si 是
AND
,则 yi=yi−1landxi;如果 Si 是 OR
,则 yi=yi−1lorxi。
这里,alandb 和 alorb 是逻辑运算符。
约束条件
- 1leqNleq60
- Si 是
AND
或 OR
。
输入
从标准输入读入数据,输入格式如下:
N
S1
vdots
SN
输出
打印答案。
示例输入 1
2
AND
OR
示例输出 1
5
例如,如果 $(x_0,x_1,x_2)=(\\text{True},\\text{False},\\text{True})$,则有 y2=textTrue,如下所示:
- 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}$
所有导致 y2=textTrue 的五个元组 (x0,x1,x2) 如下:
- (textTrue,textTrue,textTrue)
- (textTrue,textTrue,textFalse)
- (textTrue,textFalse,textTrue)
- (textFalse,textTrue,textTrue)
- (textFalse,textFalse,textTrue)
示例输入 2
5
OR
OR
OR
OR
OR
示例输出 2
63
除了全部填充为 textFalse 的元组之外,所有的元组都导致 y5=textTrue。