1 #include<iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<cmath>
5 using namespace std;
6 int n,m;
7 int fastpow(int a,int b)
8 {
9 int r=1;
10 int base=a;
11 while(b!=0)
12 {
13 if(b%2==1)
14 r=(r*base)%m;
15 base=(base*base)%m;
16 b=b/2;
17 }
18 return r;
19 }
20 int main()
21 {
22
23 scanf("%d%d",&n,&m);
24 //n=n-1;
25 cout<<fastpow(2,n)%m;
26 return 0;
27 }