1 #include <bits/stdc++.h>
2 #define _for(i,a,b) for(int i = (a);i < b;i ++)
3 #define _rep(i,a,b) for(int i = (a);i > b;i --)
4 #define INF 0x3f3f3f3f
5 #define MOD 1000000007
6 #define maxn 150003
7 typedef long long ll;
8
9 using namespace std;
10 typedef pair<int,int> P;
11 inline ll read()
12 {
13 ll ans = 0;
14 char ch = getchar(), last = ' ';
15 while(!isdigit(ch)) last = ch, ch = getchar();
16 while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
17 if(last == '-') ans = -ans;
18 return ans;
19 }
20 inline void write(ll x)
21 {
22 if(x < 0) x = -x, putchar('-');
23 if(x >= 10) write(x / 10);
24 putchar(x % 10 + '0');
25 }
26 bitset<32> a(0),b(1073741823),ans(0),start(0);
27 int n,m;
28 string order;
29 int main()
30 {
31 // freopen("testdata.in","r+",stdin);
32 n = read(),m = read();
33 _for(i,1,n+1)
34 {
35 cin >> order;
36 int c = read();
37 if(order=="AND")
38 a &= c,b &= c;
39 else if(order=="OR")
40 a |= c,b |= c;
41 else
42 a ^= c,b ^= c;
43 }
44 // cout << b[0] << endl;
45 _rep(i,32,-1)
46 if(a[i])
47 ans[i] = 1;
48 else if(b[i] && start.to_ulong()<=m)
49 {
50 start[i] = 1;
51 if(start.to_ulong()<=m)
52 ans[i] = 1;
53 else
54 start[i] = 0;
55 }
56 printf("%d\n",ans.to_ulong());
57 return 0;
58 }