#include<cstdio> #include<cstring> using namespace std; const int maxn=1000+5; int mod; int main(){ char in[maxn]; while(scanf("%s%d",in,&mod)==2){ int len=strlen(in),ans=0; for(int i=0;i<len;i++) ans=(ans*10+in[i]-'0')%mod; printf("%d ",ans); } }
HDU1212