#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ALL(g) (g).begin(),(g).end() #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define F(i,j,k) fill(i[0],i[0]+j*j,k) #define P(p) cout<<(p)< vi; typedef vector vl; typedef vector vd; typedef pair pii; typedef pair pll; typedef long long ll; int main(){ ll N,M; int mod=1<<10; cin>>N>>M; int pascal[10001][10001]; for(int i=0;i<=10000;i++){ for(int j=0;j<=i;j++){ if(j==0)pascal[i][j]=1; else pascal[i][j]=(pascal[i-1][j]+pascal[i-1][j-1])%mod; } } int amari=N/1000%M; cout<