/*
#include <stdio.h>
int main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
printf("%d\n",a+b+c);
printf("%.1f",(float)(a+b+c)/3);
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d+%d=%d\n",a, b, a+b);
printf("%d-%d=%d\n",a, b, a-b);
printf("%d*%d=%d\n",a, b, a*b);
printf("%d/%d=%d\n",a, b, a/b);
return 0;
}
*/
/*
#include <stdio.h>
int main ()
{
int a;
scanf("%d",&a);
printf("%d ",a/60);
printf("%d",a%60);
}
#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%.1f",(float)a*b/2);
}
*/
/*
#include <stdio.h>
int main ()
{
int a;
scanf("%d",&a);
printf("%.3f",(float)9/5*a+32);
}
*/
/*
#include <stdio.h>
int main()
#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%.1f",(float)a*b/2);
}
{
int a,b;
scanf("%d %d",&a,&b);
printf("%.1f",(float)a*b/2);
}
*/
/*
#include <stdio.h>
int main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
printf("%.2f",(float)(a+b+c)/3)
*/
#include <stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d\n",a%b);
}