1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>
using namespace std;
int n, wyn=0;
string slo;
int wczyt(int i)
{
	int wyn=0;
	while (slo[i]>='0' && slo[i]<='9')
	{
		wyn*=10;
		wyn+=slo[i]-'0';
		i++;
	}
	//cout << wyn << "w ";
	return wyn;
}
int check(int zb)
{
	//cout << zb << "\n";
	int otw=0, tr=0;
	for (int i=0; i<slo.size(); i++)
	{
		if (slo[i]=='(')
		{
			otw=1;
			tr=0;
		}
		if (slo[i]==')')
		{
			//cout << i << " ";
			otw=0;
			if (tr==0)
				return 0;
		}
		if (slo[i]=='x')
		{
			int num=wczyt(i+1);
			int mod=0;
			if (slo[i-1]=='~')
				mod=1;
			//cout << (zb&(1<<(num-1))) << "zb " << zb << " " << num-1 << " " << (1<<(num-1)) << "   ";
			if ((zb&(1<<(num-1)))!=0 && mod==0)
				tr=1;
			if ((zb&(1<<(num-1)))==0 && mod==1)
				tr=1;
		}
	}
	return 1;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n;
	getline(cin, slo);
	getline(cin, slo);
	for (int i=0; i<(1<<n); i++)
	{
		wyn+=check(i);
	}
	cout << wyn;
	return 0;
}