/* */ #include #ifdef t9unkubj #define dbg(x) cout<<__LINE__<<" "<<#x<<":="<>t; for(int _=0;_>n>>m; long long N=0; reverse(n.begin(),n.end()); long long base=1; for(auto x:n){ N+=(long long)(x-'0')*base; N%=m; base*=10; base%=m; } if(m%2==0)cout<<(N*(N+1)/2)%m<