Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks?

The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space.

Print a single integer — the answer to the problem.

NoteIn the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two.In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.

#include <stdio.h>

int main()
{
    int n, m, answer;
    scanf("%d %d", &n, &m);
    if (n<1 || n>100 || m<2 || m>100) n = 0;
    answer = n;
    while (n>=m)
    {
        answer += n/m;
        n = n/m + n%m;
    }
    printf("%d", answer);
}

#include<stdio.h>
int main()
{
    int a,b,h,nc;
    scanf("%d%d",&a,&b);
    h=a;
    while(1)
    {
        nc=a/b;
        a=nc+(a%b);
        h=h+nc;
        if(a<b)break;
    }
    printf("%d",h);
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n = 0, m = 0, ans = 0, total = 0, additional = 1;
    scanf("%d %d", &n, &m);
    ans += n;
    while(additional != 0)
    {
        additional = 0;
        while(n/m != 0)
        {
            additional += n%m;
            n /= m;
            ans += n;
            //printf("aa %d %d ", n, n%m);
            //printf("%d\n", additional);
        }
        additional += additional+n%m >= m? n%m: 0;
        n = additional;
        total += additional;
    }
    //printf("%d\n", total);
    printf("%d", ans+additional/m);
}

#include<stdio.h>

int main(){
        int n,m, sum = 0;
        scanf("%d %d",&n, &m);
        while( n >0){
                n --;
                sum ++;
                if( sum != 0 && sum % m == 0)
                        n ++;
                }

        /*if ((n/m) != 0 && (n/m) % m == 0)
                sum = n + (n/m) + 1;
        else
                sum = n + (n/m);*/
        printf("%d",sum);
        return 0;
}

#include <stdio.h>

int main() {
	int n, m, dia=0;

	scanf("%d", &n);
	scanf("%d", &m);

	while(n>0) {
		++dia;
		--n;
		if((dia)%m==0) ++n;
	}

	printf("%d", dia);
	return 0;
}

#include<stdio.h>
int main()
{
    int a, n, m, i, sum=0, repeat;
    scanf("%d %d", &n, &m);
    sum = n + n/(m-1);
    if(n%(m-1) == 0){
        sum -= 1;
    }
    printf("%d", sum);

    return 0;
}

#include<stdio.h>
int main(void)
{
    int i,n,m,total,extra;
    scanf("%d %d",&n,&m);
    total=n;
    for(i=0;;i++)
    {
        extra=n/m;
        if(extra==0)
            break;
        if(n%m!=0&&n>m)
            n=extra+n%m;
        else
            n=extra;
        total+=extra;
    }
    printf("%d\n",total);
    return 0;
}

#include<stdio.h>
int main(){
    int i,s,r,l,j,n;
    scanf("%d %d",&n,&j);
    l=n/j;
    r=n%j;
    for(;;){
        if(l==0) break;
        n=n+l;
        s=l%j;
        l=l/j;
        r=r+s;

    }
    if(r>j) n=n+((r/j));
    if(n%j==0) printf("%d",n+1);
    else printf("%d",n);
}

#include<stdio.h>
int main()
{
int n,m,c,r,x;
scanf("%d %d",&n,&m);
c=n;
while((n/m)>=1)
{x=n%m;
c=c + n/m;
if(x==0)
n=n/m;
if(x!=0)
{
n=n/m + x;}}
printf("%d",c);
return 0;}

#include<stdio.h>

int main()
{
	int n, m;
	while (~scanf("%d %d", &n, &m))
	{
		int cnt = 0, day = 0;
		while (n)
		{
			n--;
			cnt++;
			if (cnt == m)
			{
				n++;
				cnt = 0;
			}
			day++;
		}
		printf("%d\n", day);
	}
	return 0;
}

#include<stdio.h>
int main ()
{
    int a,c=0,b,n=0;
    scanf("%d%d",&a,&b);
    n=a;
    c=a;
    while(c>=b)
    {
        n+=c/b;
        c=c%b+c/b;
    }
    printf("%d",n);
    return 0;
}

#include <stdio.h>

int main(){
	int n, m, i;
	scanf("%d %d", &n, &m);

	for(i = 0; i < n; i++){
			if(i%m == 0)
				n++;
		}
	printf("%d", n - 1);

	return 0;
}

#include<stdio.h>
int main()
{
	int n,m,i;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
    if(i%m==0)
    n++;
	printf("%d",n);
	return 0;
}

#include<stdio.h>
int main()
{
    int n,m,x;

scanf("%d %d",&n,&m);

if(n==m)

{

x=((n*m)+n)/n;

}

else if(n<m)

{

x=(n*m)/m;

}

else

{

x=((n-1)/(m-1))+n;

}

printf("%d\n",x);

}

#include<stdio.h>
int main()
{
    int n,m,sum,i,j,d;
    scanf("%d %d",&n,&m);
    sum=0;

    for(i=n;i>=m;i=i/m+i%m)
    {
        sum=sum+(i/m)*m;
    }
    d=sum+i;
    printf("%d\n",d);
    return 0;
}

#include <stdio.h>
int main()
{
   int n,m;
   int i;
   int count = 0;
   scanf("%d %d",&n,&m);
   for(i = 1; ; i++)
   {
      if(i%m == 0)
        count++;
      if(i>n)
      {
          count--;
          }
          if(count == 0 && i>=n)
          break;
      }
      printf("%d\n",i);
      return 0;

   }

#include<stdio.h>
int main(){
	int n,m,s=0,a=0,x;
	scanf("%d %d",&n,&m);
   while(n>=m)
    {s+=n/m *m;
    n=n/m+n%m;
}
printf("%d",s+n);
}

#include<stdio.h>
int main()
{

    int n,m,i=1,flag=1,temp,count=0;
    scanf("%d%d",&n,&m);
    int c=n+1;
    int d=n+n/m;

        while(flag)
        {
            flag=0;
            temp=count;
            for(i=c; i<=d; i++)
            {

                if(i%m==0)
                {
                    count++;
                    flag=1;
                }

            }
            c=d+1;
            d=d+count-temp;
        }
       printf("%d",n+n/m+count);

    return 0;

}

#include<stdio.h>
int main()
{
    int n,m,sum,d;
    scanf("%d %d",&n,&m);
    sum=n;
    rich:
    d=n/m;
    if(d>0)
    {
    sum=sum+d;
    if(((n%m)+d)>=m)
    {
    n=(n%m)+d;
    goto rich;
    }
    }
    printf("%d",sum);
    return 0;
}

#include<stdio.h>
int main()
{
    int n, m,sum;
    scanf("%d %d",&n,&m);
    sum =n;
    while(n>=m)
    {
        sum=sum +(n/m);
        n=((n/m)+(n%m));
    }
    printf("%d\n", sum);
    return 0;
    }

#include<stdio.h>
int main(){
    int l,n,i,j,a,b,m,c=0;
    scanf("%d %d",&n,&m);
    a=n/m;
    l=0;
    b=n;
    for(i=1;a!=0;i++){
        if(b%m==0){
            l=l+a;
            b=a;
            a=a/m;
            b=b%m;
        }
        else{
            l=l+a;
            a=a+b%m;
            b=a;
            a=a/m;
        }
    }
    printf("%d\n",l+n);
    return 0;
}

#include<stdio.h>
int main(void)
{
    int n,t,m,c,k;
    scanf("%d",&n);
    t=n;
    c=0;
    scanf("%d",&m);
    while(n/m!=0)
    {
        k=n%m;
        n=n/m;
        c=c+n;
        n=n+k;
    }
    printf("%d",c+t);
    return 0;
}

#include<stdio.h>
int main()
{
    int a,b,c=0,d,i=2;
    scanf("%d %d",&a,&b);
    d=b;
    while(a>=d)
    {
        c=0;
        while(1)
        {
            if(d<=a){
                c++;
                d=b*i;
                i++;
                }
            else break;
        }
        a=a+c;
    }
    printf("%d",a);
    return 0;
}

#include <stdio.h>
int main()
{
	int n,m,d,aux;
	scanf("%d%d",&n,&m);
	d = 0;
	do
	{
		aux = n;
		n -= m;
		if (n < 0)
		{
			d += aux;
			break;
		}
		d += m;
		n++;
	}
	while (1);
	printf("%d",d);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, m, a;
    scanf("%d%d", &n, &m);
    a=n+(n-1)/(m-1);
    printf("%d", a);
    return 0;
}

#include<stdio.h>
int main(int argc, char const *argv[]) {
  int a,b;
  scanf("%d %d", &a,&b);
  printf("%d\n", (a*b-1)/(b-1));
  return 0;
}

#include<stdio.h>
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int temp=n,count=0;
    while(temp>1&&n>=m){
        temp=temp-m+1;
        count++;
        if(temp<m)break;
    }
    printf("%d\n",n+count);
    return 0;
}

#include <stdio.h>

int main()
{
    int n, m, answer;
    scanf("%d %d", &n, &m);
    if (n<1 || n>100 || m<2 || m>100) n = 0;
    answer = n;
    while (n>=m)
    {
        answer += n/m;
        n = n/m + n%m;
    }
    printf("%d", answer);
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void)
{
	int n,m,a,b,k,count,j;
	scanf("%d%d",&n,&m);
	 j=-1;
	count=0;
	a=n+1;
    b=n+n/m;
    while(1)
    {
      for(k=a;k<=b;k++)
      {
      	if(k%m==0)
      	count++;
      }
      a=a+n*pow(m,j);
      b=b+n*pow(m,j-1);
      j--;
      if(a>b)
      break;
    }
    if((n+n/m+count)%m==0)
    printf("%d",n+n/m+count+1);
    else
    printf("%d",n+n/m+count);
}

#include <stdio.h>
int main()
{
	int n,m,flag=0;
	scanf("%d %d",&n,&m);
	do
	{
		flag+=1;
		n-=1;
		if(flag%m==0) n+=1;
	}while(n!=0 || flag%m==0);
	printf("%d",flag);
}

#include<stdio.h>
int main ()
{
    int m,n,a, b, x,i;

    scanf("%d %d",&n, &m);
    x=n;
    for (i=1; ;)
    {
    	a=n/m;
    	b=a+(n%m);
    	n=b;
    	x=x+a;
    	if (b<m)
    	{break;}
    }
    printf("%d", x);

        return 0;
}

#include<stdio.h>
int main()
{
 int a,b,i;
 scanf("%d %d",&a,&b);
for(i=1;i<250;i++)
{
    a=a-1;
    if(i%b==0) a=a+1;
    if(a==0)   break;
}
printf("%d\n",i);
}

#include<stdio.h>
int main()
{
    int a,b,h,nc;
    scanf("%d%d",&a,&b);
    h=a;
    while(1)
    {
        nc=a/b;
        a=nc+(a%b);
        h=h+nc;
        if(a<b)break;
    }
    printf("%d",h);
}

#include<stdio.h>
int main()
{
    int n,m,x;

scanf("%d %d",&n,&m);

if(n==m)

{

x=((n*m)+n)/n;

}

else if(n<m)

{

x=(n*m)/m;

}

else

{

x=((n-1)/(m-1))+n;

}

printf("%d\n",x);

}

#include <stdio.h>
#include <string.h>

int main()
{
   int i,a,b,n,m;
   scanf("%d %d",&n,&m);
   i=n;
   while(1)
   {
       if(n<m) break;
       else{a=n/m;b=n%m;
       i=i+a;n=a+b;
       }
   }
   printf("%d",i);
}

#include<stdio.h>
#include<math.h>
int main()
{int n,m,i,count=0,l;

float p1,p2,p=0.0;
scanf("%d%d",&n,&m);
for(i=1;(n/pow(m,i))>=1.00;i++)
  {
    p1=(n/pow(m,i));
    p=p+p1;
    count=count+1;
  }
l=count+1;
p2=n+p+(n/pow(m,l));
printf("\n%d",(int)p2);

    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,days =  0;
    scanf("%d%d",&n,&m);
    while(n >= m)
    {
        int remainder = n%m;
        days += n - remainder;
        n /= m;
        n += remainder;
    }
    days += n;
    printf("%d\n",days);
    return 0;
}

#include<stdio.h>
int main (){
	int n, m;
	scanf("%d %d", &n, &m);
	int i, count = 0;
	for(i = 1; 0 <(n + count); i++){
		n--;
		if(i % m == 0) count++;
	}
	printf("%d", --i);
}

#include<stdio.h>
int main()
{
    int n,m,count=0,i;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
    {
        count=count+1;

            if(i%m==0)
            {
                count=count+1;
                n=n+1;
            }

    }
    printf("%d",n);

}

#include<stdio.h>

int main()

{
	int i=0,n,m;
	scanf("%d%d",&n,&m);
	printf("%d",n+((n-1)/(m-1)));
	return 0;

}

#include<stdio.h>

int main(){
	int n=0,m=0,DIAS=0,CANT=0,C=0;
	scanf("%d %d",&n,&m);
	CANT=n;
	while(CANT > 0){
		C=C+1;
		CANT=CANT-1;
		DIAS=DIAS+1;
		if(DIAS%m==0){
			CANT = CANT + 1;
		}
	}
	printf("%d",C);
	return 0;
}

#include <stdio.h>

int main()
{
    int n,m,sum=0,div,check,count=0,res;
    scanf("%d %d",&n,&m);
    sum=n;
    div=sum/m;
    res=sum%m;
    sum=sum+div;
    div=div+res;
    while(1){
        res=div%m;
        div=div/m;
        sum=sum+div;
        div=div+res;
        if(div<m)
            break;
    }
    printf("%d",sum);
    return 0;
}

#include<stdio.h>
int main(int argc, char const *argv[]) {
  int a,b;
  scanf("%d %d", &a,&b);
  printf("%d\n", (a*b-1)/(b-1));
  return 0;
}

#include<stdio.h>

int main()
{
    int m,n,p=0;
    scanf("%d %d",&n,&m);
    if(m!=1)
        p=((n-1)/(m-1));
    n+=p;
    printf("%d\n",n);
    return 0;
}

#include <stdio.h>

int main(){
	int n, m, i, days = 0;
	scanf("%d %d", &n, &m);

	if(n == m){
		printf("%d", n + 1);
	}
	else if(n < m){
		printf("%d", n);
	}
	else{
		for(i = 0; i < n; i++){
			if(i%m == 0)
				n++;
		}
		printf("%d", n - 1);
	}
	return 0;
}

    #include<stdio.h>
    int main()
    {
        int n, m, x, a;
        scanf("%d %d", &n, &m);
        x=n;
        while(1)
        {
            a=n/m;
            n=a+(n%m);
            x+=a;
            if(n<m)
                break;
        }
        printf("%d", x);
        return 0;
    }

#include<stdio.h>
int main()
{
    int n,m,i,c=0,o;
    scanf("%d%d",&n,&m);
    o=n;
    for(int i=1;i<=n;i++)
    {
        if(i%m==0)
         {
             c++;
             n++;
         }

    }
   // printf("%d",c);
    printf("%d\n",c+o);

}

#include<stdio.h>
int main()
{
int n,m,i;
scanf("%d %d",&n,&m);
for(i=1;i>0;i++)
{
n=n-1;
if(i%m==0)
n=n+1;
if(n==0)
break;
}
printf("%d",i);
return 0;

}

#include <stdio.h>

int main() {
	int a,b,n;
	scanf("%d %d",&a,&b);
	n=a+(a-1)/(b-1);
	printf("%d",n);
	return 0;
}

#include <stdio.h>

int main(void){
    int n,m;
    int c=0;

    do{
        scanf("%d%d", &n,&m);
    }while(n<=0 || m<=0) ;

    while(n>0){
        n--;
        c++;
        if (c%m==0){
			n++;
		}
    }

    printf("%d", c);

    return 0;
}

#include<stdio.h>
int main(){
    int n,m,count=0;
    scanf("%d %d",&n,&m);
    while(n>m){
        n = n-(m-1);
        count+=m;
    }
    if(n==m)
        printf("%d",count+n+1);
    else
        printf("%d",count+n);
    return 0;
}

#include <stdio.h>
int main()
{
	int n,m,flag=0;
	scanf("%d %d",&n,&m);
	do
	{
		flag+=1;
		n-=1;
		if(flag%m==0) n+=1;
	}while(n!=0 || flag%m==0);
	printf("%d",flag);
}

#include <stdio.h>

int main()
{
  int n,m,i;
  scanf("%d %d",&n,&m);

  for (i=1;;i++){
     if (n==0)
      break;
    n--;
    if (i%m==0)
      n++;
  }

    printf("%d\n",i-1);
  return 0;
}

#include<stdio.h>
int main()
{
    int n,m,cnt=0;
    scanf("%d %d",&n,&m);
    for(int i=0;n>=0;i++,n--)
    {
        cnt++;
        if(i==m)
        {
            n++;
            i=0;
        }
    }
    printf("%d",cnt-1);
    return 0;
}

#include<stdio.h>
int main()
{
    int m,n,k,i;
    scanf("%d %d",&n,&m);
    for(i=1;i<=n;i++)
    {
        if(m*i<=n)
            n++;
    }
    printf("%d",n);
    return 0;
}

#include <stdio.h>

int main(void) {
	// your code goes here
	int n,m,i;
	scanf("%d %d",&n,&m);
    for(i=1;i<=n;i++)
    {
        if(i%m==0)
        n=n+1;
    }
	printf("%d",i-1);
	return 0;
}

#include <stdio.h>
int main()
{
    int a,b,i=0,m;
    scanf("%d %d",&a,&b);
    m=a;
    while(a>=b){
        a=(a-b)+1;
        i++;
    }
    printf("%d",m+i);
}

#include<stdio.h>
int main(){
    int n,m,i;
    scanf("%d%d",&n,&m);
    for(i=0,n-=1;n>=0;i++){
        if(i%m)
            n--;
    }
    printf("%d",i-1);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,d,i;
    scanf("%d %d",&n,&d);
    for(i=1;d*i<=n;i++)
    {
        n++;
    }

    printf("%d",n);

    }

#include<stdio.h>
int main()
{
	int n,m,days=0;
	scanf("%d %d",&n,&m);
	do
	 {days++;
	  n--;
	  if(days%m==0)
	   n++;}
	while(n!=0||days%m==0);
	printf("%d",days);
	}

#include <stdio.h>
int main ()
{
int n,m,x,y,z,s,a;
s=0;
scanf ("%d %d", &n,&m);
s=s+n;
x=(int)n/m;
s=s+x;
y=x*m;
z=n-y;
x=x+z;
while(x >= m)
{
n=x;
x=(int)x/m;
s=s+x;
y=x*m;
z=n-y;
x=x+z;
}
printf ("%d\n", s);
return 0;
}

#include <stdio.h>

int main(){
	int n, m, i;
	scanf("%d %d", &n, &m);

	for(i = 0; i < n; i++){
			if(i%m == 0)
				n++;
		}
	printf("%d", n - 1);

	return 0;
}

#include<stdio.h>
int main()
{
    int n,m,days=0,socks;
    scanf("%d %d",&socks,&m);
    while(socks!=0)
    {
        days++;
        socks--;
        if(days%m==0)
         socks++;
    }
    printf("%d",days);
    return 0;
}

#include<stdio.h>
int main()
{
    int m,n,days=0,c=0,i;
    scanf("%d%d",&n,&m);
    i=n+1;
    days+=(n+(n/m));
   // printf("n");
    while(1)
    {
        c=0;
        for(;i<=days;i++)
        {
            if(i%m==0) c++;
        }
             days+=c;
        if(c<m) break;
    }
   if(days%m==0) days++;
    printf("%d",days);
    return 0;

}

        #include <stdio.h>

        int main(){
            int p,n,m;
            scanf("%i %i",&n,&m);
            int q=n;
            while(n/m>0){
                p=n/m;
                q+=p;
                n=n%m+p;
            }
            printf("%i",q);
        }

#include<stdio.h>
int main()
{
    int n,m,s,q;
    scanf("%d %d",&n,&m);
    if(n<m)
    {
        printf("%d",n);
    }
    else
    {
        s=n;
        while(n!=0)
        {
            q=n%m;
            n=n/m;
            s=s+n;
            if(n==0)
            {
                break;
            }
           n=n+q;

        }
        printf("%d",s);
    }

}

#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {
    int m,n;
    scanf("%d %d",&m,&n);
    int sum;
    sum=m+(m-1)/(n-1);
    printf("%d",sum);
     return 0;
}

#include<stdio.h>
int main()
{
int n,m,c,r,x;
scanf("%d %d",&n,&m);
c=n;
while((n/m)>=1)
{x=n%m;
c=c + n/m;
if(x==0)
n=n/m;
if(x!=0)
{
n=n/m + x;}}
printf("%d",c);
return 0;}

#include <stdio.h>

int main() {
	int n, m, dia=0;

	scanf("%d", &n);
	scanf("%d", &m);

	while(n>0) {
		++dia;
		--n;
		if((dia)%m==0) ++n;
	}

	printf("%d", dia);
	return 0;
}

#include<stdio.h>

int main()
{
    int m,n,j,a,b,c;

    scanf("%d %d",&m,&n);
    a=1;
    b=m;
    for(;a<b;)
    {
        c=0;
        for(j=a;j<=b;j++)
        {
        if(j%n==0)
        c++;
        }
        a=b+1;
        b=b+c;

    }
    if(b%n==0)

     printf("%d",b+1);
     else printf("%d",b);

    return 0;
}

#include<stdio.h>
int main()
{
    long n,m,s;
    scanf("%d%d",&n, &m);
    s=n;
    while(n>=m)
    {
        s+=n/m;
        n=n%m+n/m;
    }
    printf("%d\n",s);
    return 0;
}

//
//  main.c
//  jsd
//
//  Created by Mihai Esanu on 10/5/19.
//  Copyright © 2019 Mihai Esanu. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    int day, n, m;

    scanf("%d %d", &n, &m);
    day = 0;
    while(1==1)
        {
            n = n - 1;

            day = day + 1;
        if( day % m == 0 )
        {
            n = n + 1;
        }
            if(n == 0)
            {
                break;
            }
        }

    printf("%d", day);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,count=0,i,x;
    scanf("%d%d",&n,&m);
    x=m;
    for(i=1;n>0;i++)
    {
        n=n-1;
        count++;
        if(i==m)
        {
            n=n+1;
            m=m+x;
        }
    }
    printf("%d",count);
    return 0;

}

#include <stdio.h>
#include <string.h>

int main()
{
   int i,a,b,n,m;
   scanf("%d %d",&n,&m);
   i=n;
   while(1)
   {
       if(n<m) break;
       else{a=n/m;b=n%m;
       i=i+a;n=a+b;
       }
   }
   printf("%d",i);
}

#include<stdio.h>
#include<math.h>
void math()
{
    int n,m,d;
    scanf("%d%d",&n,&m);
   if(n<m)
        printf("%d\n",n);
   else if(n==m)
        printf("%d\n",++n);
    else
   {
      d=n+(n-1)/(m-1);
      printf("%d\n",d);
    }

   }

int main()
{
    math();
}

#include<stdio.h>

int main()

{
	int i=0,n,m;
	scanf("%d%d",&n,&m);
	printf("%d",n+((n-1)/(m-1)));
	return 0;

}

#include <stdio.h>
main()
{
    int n,m,a=0;
    scanf("%d %d",&n,&m);
    while(n>0)
    {
    	a=a+1;
    	if(a%m==0)
    	{
    		n=n;
		}
		else
		{
			n=n-1;
		}
	}
	printf("%d",a);

}

#include <stdio.h>

int main(void){
    int n,m;
    scanf("%d %d",&n,&m);
    if((n<1)||(n>100))
        return 0;

    if((m<2)||(m>100))
        return 0;

    if(m>n){
        printf("%d",n);
        return 0;
    }
    int result = n;
    int ratio = n/m;
    result += ratio;
    int i,j,count=1;
    while(count){
        count = 0;
        for(j=result-ratio+1;j<=result;j++){
            if(!(j%m)){
                count++;
            }
        }
        result += count;
        ratio = count;
    }
    printf("%d",result);
    return 0;
}

#include<stdio.h>
main()
{

int  n,m;
int p,s;
scanf("%d%d",&n,&m);
p=n;
while(n>=m)
{p=p+(n/m);

s=n-(n/m)*m;
n=s+(n/m);
//printf("%d # %d",p,n);
}
printf("%d",p);
}

#include<stdio.h>
int main ()
{
    int m,n,a, b, x,i;

    scanf("%d %d",&n, &m);
    x=n;
    for (i=1; ;)
    {
    	a=n/m;
    	b=a+(n%m);
    	n=b;
    	x=x+a;
    	if (b<m)
    	{break;}
    }
    printf("%d", x);

        return 0;

}

#include<stdio.h>
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    int a,i;
    for(i=1;;i++)
    {
        a=i*m;
        if(n>=a)
        n++;else break;

    }
    printf("%d\n",n);
return 0;
}

#include<stdio.h>
int main(){
int n,m,d=0;
scanf("%d%d",&n,&m);
while(n/m>0){
d+=n-n%m;
n=(n/m)+(n%m);
}
d+=n;
printf("%d",d);
return 0;
}

#include <stdio.h>
int main()
{
	int m,n,pairs,temp;
	scanf("%d%d",&m,&n);
	pairs=m;
	while(m/n!=0){
		temp=m/n;
		pairs=pairs+temp;
		m=temp+m%n;
	}
	printf("%d",pairs);
	return 0;
}

#include<stdio.h>

int main(){
	int n=0,m=0,DIAS=0,CANT=0,C=0;
	scanf("%d %d",&n,&m);
	CANT=n;
	while(CANT > 0){
		C=C+1;
		CANT=CANT-1;
		DIAS=DIAS+1;
		if(DIAS == m){
			CANT = CANT + 1;
			DIAS=0;
		}
	}
	printf("%d",C);
	return 0;
}

#include <stdio.h>
#include <math.h>

int main(void) {
  int n, m;
  scanf("%d %d", &n, &m);

  int x = n;
  if (n >= m)
    while (x >= m) {
      int r = x % m;
      x = x / m;
      n += floor(x);
      x += r;
    }
  printf("%d\n", n);

  return 0;
}

#include<stdio.h>
#define sf scanf
#define pf printf
typedef long long ll;

int main()
{
    int a, b, div, mod;
    sf("%d%d", &a, &b);
    int sum = a;
    while(a>=b)
    {
        div = (a/b);
        sum = sum + div;
        mod = (a%b);
        a= (div+mod);
    }
    pf("%d\n", sum);
}

#include<stdio.h>

main()
{
    int n,m,i,x,y;
    scanf("%d %d",&n,&m);
    x=n;
    if(m!=2&&n>=m)
    {for(i=1;i<=n;i++)
    {y=n%m;
    n=n/m;
    x=x+n;
    if(m>n&&y==0)
        break;
        else
    n=n+y;
     }
   printf("%d",x);}
    else if(m==2) printf("%d",2*n-1);
    else if(m>n)
        printf("%d",n);
    return 0;
}

#include <stdio.h>
int main()
{
    int a,b,i=0,m;
    scanf("%d %d",&a,&b);
    m=a;
    while(a>=b){
        a=(a-b)+1;
        i++;
    }
    printf("%d",m+i);
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
int n,m,daysCnt=0,i,NewSocs,remindDays,temp;
scanf("%i%i",&n,&m);

  daysCnt=n;
  NewSocs=n/m;
  remindDays=n%m;
  daysCnt= daysCnt+NewSocs;

  while (NewSocs!=0)
 {  temp=NewSocs;
   NewSocs=(temp+remindDays)/m;
   remindDays=(temp+remindDays)%m;
   daysCnt=daysCnt+NewSocs;
 }

  printf("%i",daysCnt);

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, m, a;
    scanf("%d%d", &n, &m);
    a=n+n/m+n/(m*m)+n/(m*m*m)+n/(m*m*m*m)+n/(m*m*m*m*m);
    printf("%d", a);
    return 0;
}

#include<stdio.h>
#include <conio.h>

int main()
{
	int n,m,sum,div;
	scanf("%d%d",&n,&m);
	sum=n;
	while(n/m!=0)
	{
		div=n/m;
		sum=sum+div;
		n=n/m;

	}
	if(sum%m==0)
		sum++;

	printf("%d",sum);

	//getch();
	return 0;
}

#include<stdio.h>
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int temp=n,count=0;
    while(temp>1&&n>m){
        temp=temp-m+1;
        count++;
    }
    printf("%d\n",n+count);
    return 0;
}

#include <stdio.h>
#include <math.h>
#define ll long long

int main()
{
    int n,m,count = 0, s;
    scanf("%d %d",&n,&m);
    s = n;
    for( ; n/m != 0; ){
        s = s + n/m;
        n = n/m;
    }
    printf("%d",s);

    return 0;
}

    #include<stdio.h>
    int main()
    {
        int n,m,res,mod=0;
        scanf("%d%d",&n,&m);
        res=n;
        while(n>=m)
        {
            res=res+(n/m);
            mod=mod+(n%m);
            n=n/m;
        }
        printf("%d",res+mod);
        return 0;
    }

#include<stdio.h>
int main ()
{
    int m,n,x,i;
    x=0;
    scanf("%d %d",&n, &m);

        if(m+1>n) printf("%d",n);

        else if(m<n) {
           for (i=1;i<=m; i=i+1)
        {
            x=x+1;
        }  printf("%d", n+1+x);
       }
        return 0;

}

#include <stdio.h>

int main()
{
	int n,m, day=0;

	scanf("%d %d", &n, &m);

	while(1)
	{
		n--;
		day++;

		if(n==0)
			break;

		if(day%m==0)
			n++;
	}

	printf("%d", day);

	return 0;
}

#include<stdio.h>
int main()
{
    int n,m,i,count=0;
    scanf("%d %d",&n,&m);

    if(n==m) printf("%d",n++);

    if(n<m) printf("%d",n);

    if(n>m){
    for(i=1;i<=n;i++){
        if(i%m==0){
            n++;
            count++;
        }
        else count++;
    }
    printf("%d",count);
    }
}

#include <stdio.h>
int main()
{
    int n,m,sum;
    scanf("%d%d",&n,&m);
    if(n<m)
        sum=n;
    else{
        if((n+n/m)%m==0)
            sum=n+n/m+1;
        else
            sum=n+n/m;
    }
    printf("%d\n",sum);
    return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
    float n, m;
    int answer;

    scanf("%f %f", &n, &m);

    if (n<1 || n>100 || m<2 || m>100) n = 0;
    answer = 0;

    while (n>=1)
    {
        answer += n;
        n /= m;
    }
    if (n>0.5) answer++;

    printf("%f %f %d", n, m, answer);
}

#include <stdio.h>

int main(void) {
	int p,q,x;
	scanf("%d %d",&p,&q);
	x=p+p/q;
	while((p/q)>=q)
	{
		if(p%q==0){
				p=p/q;
		x=x+p/q;
			p=p/q;
		}

		else{
				p=p/q;
		x=x+(((p%q)+(p/q))/q);
		p=p/q;}
	}
	printf("%d",x);
	return 0;
}

#include <stdio.h>
#include <math.h>
#define ll long long

int main()
{
    int n,m,s = 0,e = 0,f = 0;
    scanf("%d %d",&n,&m);
    s = n;
    for( ; n/m != 0; ){
        s = s + n/m;
        e = e + n % m;
        n = n/m;
    }
    for( ; e/m != 0; ){
        f = f + e/m;
        e = e/m;
    }

    printf("%d",s + e);

    return 0;
}

#include <stdio.h>

int main(int argc, const char * argv[]) {
    int day, n, m;

    scanf("%d %d", &n, &m);
    day = 1.0;
    while(1==1)
        {
            n = n - 1;
            if(n == 0)
            {
                break;
            }
        if( day % m > 0 )
        {
            n = n + 1;
        }
            day = day + 1;
        }
    printf("%d", day);
    return 0;
}

#include <stdio.h>
int main()
{
    int n,m,sum;
    scanf("%d%d",&n,&m);
    if(n==0||m<=1||n>100||m>100) return 0;
    if(n<m)
        sum=n;
    else{
       sum=n;
       while(n/m>1)
       {
           n=n/m;
           sum=sum+n;
       }
       sum=sum+1;
    }
    printf("%d\n",sum);
    return 0;
}

#include <stdio.h>

int main(){
	int n,m, r;
	scanf("%d %d", &n,&m);
	r = n;
	while ( n != 0){
		r += n / m;
		n = n / m;
	}
	printf("%d", r);
	return 0;
}

#include<stdio.h>
int main()
{
	int m,n,i,j;
	scanf("%d %d",&n,&m);
	i=n/m;
	j=n%m;
	if(i>=m){

	i=i+i-m;
	i++;
}
	printf("%d\n",n+j+i);

	return 0;
}

#include<stdio.h>
int main()
{
    int n,m,ans,ans1,b;
    scanf("%d %d",&n,&m);
    b=n/m;
    ans=n+b;
    ans1=ans;
    ans=ans-n;
//  printf("%d %d",ans1,ans);
    while(ans>=m)
    {
        b=ans/m;
        ans1=ans1+b;
        ans=ans%m;
    }
    printf("%d",ans1);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,ans;
    scanf("%d %d",&n,&m);
    ans=n+(n/m);
    n=n/m;
    do
    {
        n=n/m;
        ans+=n;
    }while(n/m);
    if(n%m==(m-1))
        ans+=n;
    printf("%d",ans);
    return 0;
}

#include<stdio.h>
int main ()
{
    int m,n,x,i,y;
    x=0;

    scanf("%d %d",&n, &m);
     n=y;
        if(m>n) printf("%d",n);

        else if(m<n)
          {
            for (i=0;i<=n; i=i+m)
        {
            x++;
            n++;
        }  printf("%d", y+x); }
        else if (m==n) { for(i=1; i<=n; i=i+m)
        {
            x++;
            n++;
        }printf("%d", y+x); }

        return 0;

}

#include<stdio.h>
int main()
{
    int n,m,ans,ans1,b;
    scanf("%d %d",&n,&m);
    b=n/m;
    ans=n+b;
    ans1=ans;
    ans=ans-n;
   // printf("%d %d",ans1,ans);
    while(ans!=0)
    {
        ans=ans/m;
        ans1=ans1+ans;
    }
    if(ans1%m==0)
     {
    printf("%d",ans1+1);
     }
    else
    printf("%d",ans1);
    return 0;
}

#include<stdio.h>
int main()
{
    int i,n,count=0,m,a=0;
    scanf("%d %d",&n,&m);
    if(n>=m){
    while(a<n){
        count++;
        a+=m;
    }
    if(count<=n&&(n+count)%m==0){
        count++;
    }
        printf("%d\n",n+count);
    }
    else{
        printf("%d\n",n);
    }
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,i,l,k,s,q,p,r;
    scanf("%d %d",&n,&m);
    if(n<m)
    {
        printf("%d",n);
    }
    else
    {
        i=n/m;
        l=i+n;
        k=l/m;
        s=n+k;
        p=s-l;
        q=p/m;
        r=q*m;
        s=s+r;
        printf("%d",s);

    }

}

#include<stdio.h>
int main(void)
{
    int i,n,m,total,extra;
    scanf("%d %d",&n,&m);
    total=n;
    for(i=0;;i++)
    {
        extra=n/m;
        if(extra==0)
            break;
        total+=extra;
        n=extra;
    }
    printf("%d\n",total);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,i=0,sum=0;
    scanf("%d%d",&n,&m);
    while(sum<n)
    {
       i++;
       sum+=m;
    }
    if(sum+m==n+i)
    {
       n=n+i+1;
    }
    else
    {
        n=n+i;
    }
    printf("%d",n);
    return 0;
}

#include<stdio.h>
int main()
{
    int n=0,m=0,sum=0,a=0,b=0;
    scanf("%d%d",&n,&m);
    if(n>=m)
    {
        a=n;
        sum=n;
        while(a!=0)
        {
            b=a%m;
            a=a/m;
            if(a==0||a==1)
            {
                sum=sum+a;
            }
            else
            {
                sum=sum+a+b;
            }
        }
    }
    else
    {
        sum=n;
    }
    printf("%d",sum);
    return 0;
}

#include<stdio.h>
int main(){

    int n,m;
    scanf("%d%d",&n,&m);
    printf("%d",n+(n/m));
    return 0;
    }

#include <stdio.h>

int main()
{
    int n,m,i,remainder,days = 0;
    scanf("%d %d",&n,&m);
    while(n > 2){
        remainder = n % m;
        days += n ;
        n = remainder + n / m;
    };
    printf("%d",days + n);

    return 0;
}

#include <stdio.h>

int main()
{
    int n,m,sum=0;
    scanf("%d %d",&n,&m);
    sum=n;
    sum=sum+n/m;
    if(sum%m==0)
        sum++;
    printf("%d",sum);
    return 0;
}

#include<stdio.h>
int main() {
    //就是新买的袜子，当天不能穿！
    //2 2
    //1 2 穿了一双，留有一双！
    //2 1 丢了一双，穿了一双，妈妈买了一双
    //3 0 没有穿的了，妈妈买的今天不能穿！
    //9 3
    //1 9 穿了一双，留有8双！
    //2 8 丢了一双，穿了一双，留有7双！
    //3 7 丢了一双，穿了一双，留有6双！买了一双
    //4 6 丢了一双，穿了一双，留有5双！+1
    //5 6 丢了一双，穿了一双，留有5双！新买的可以用了！
    //6 5 丢了一双，穿了一双，留有4双！买了一双
    //7 4 丢了一双，穿了一双，留有3双！+1
    //8 4 丢了一双，穿了一双，留有3双！新买的可以用了！
    //9 3 丢了一双，穿了一双，留有2双！买了一双
    //10 2 丢了一双，穿了一双，留有1双！+1
    //11 2 丢了一双，穿了一双，留有1双！可以用了
    //12 1 丢了一双，穿了一双，留有0双！买了一双！
    //13 0 丢了一双，穿了一双，留有1双！
    //整个模拟过程是细致，繁琐的！
	//通过了检测，但是中间过程和我的设想有不同！
    int n,m;
    scanf("%d%d",&n,&m);

    int socks=n;
    int day=1;
	    //printf("day %d: %d socks\n",day,socks);
    while(socks>0) {
	    //printf("day %d: %d socks\n",day,socks);
        day++;
        socks--;

	    //printf("day %d: %d socks\n",day,socks);
        if(day>=m && day%m==2) {
            socks++;
        }
    }
    printf("%d\n",day);
    //这个版本和我的分析是一致的！
    return 0;
}

#include <stdio.h>
int main()
{
    int n,i,m,r=0;
    scanf("%d%d",&n,&m);
    if(n>=m)
    {
        while(n>=0 && n>=m)
        {
            n=n-m+1;
            r+=m;
        }
        if(n<m)
        {
            r=r+1;
        }
    }
    else{
        r=n;
    }
    printf("%d",r);
    return 0;
}

#include <stdio.h>
int main()
{
	int n,m,sum=0,finalsum;
	scanf("%d%d",&n,&m);
	finalsum=n;
	while(1){
        if(n<m){
            break;
        }
		n=n-m;
		if(n==0){
			finalsum++;
			sum++;
			break;
		}
		else{
			sum++;
			finalsum++;
		}
	}
	printf("%d",finalsum+sum/m);
	return 0;
}

#include<stdio.h>
int main ()
{
    int a,b,n=0;
    scanf("%d%d",&a,&b);
    n=a+a/b;
    if(a%b==0 && b%2!=0)
    n=n+1;
    printf("%d",n);
    return 0;
}

#include <stdio.h>

int main()
{
  int n,m,i;
  scanf("%d %d",&n,&m);
  if (n==1){
    printf("1\n");
    return 0;
  }
  for (i=1;;i++){
    n--;
    if (n==0)
      break;
    if (i%m==0)
      n++;
  }

    printf("%d\n",i+1);
  return 0;
}

#include<stdio.h>
int main()
{
    int n,m,sum,r,o,y,d;
    scanf("%d%d",&n,&m);
    while(r!=0)
    {
        r=n/m;
        o=(n%m)+r;

        n=o;
        d=d+r;
        if(o<m)
         break;
    }
    sum=n+d;
    printf("%d",sum);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,z,p,x;
    scanf("%d %d",&n,&m);
    z=n/m;
    p=n+z;
    if(n<m)
       {
           printf("%d",n);
       }
      if(n>m)
        for (;z>=m;z=z+x)
        { x=z%m;
          z=z/m;
          p=p+z;}
       {
           printf("%d",p);

       }

    return 0;
}

#include <stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d",&a,&b);
	c=a/b;
	int d,e,f,g,h,i;
	d=c/b;
	f=d/b;
	g=f/b;
	i=f%b;
	e=c+a+d+f+g+i;
	printf("%d",e);
	return 0;
	}

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>

int main()
{
    int n,m;
    scanf("%i%i",&n,&m);
    int result=n;
    int counter = n;
    while(result > 0)
    {
        result = result/m;
        counter += result;

    }

    if(counter%m == 0)
        printf("%i\n",counter+1);
    else
        printf("%i\n",counter);

     return 0;
}

#include <stdio.h>
#include <math.h>
#define ll long long

int main()
{
    int n,m,s = 0,e = 0,f = 0;
    scanf("%d %d",&n,&m);
    s = n;
    for( ; (n+ m - 1)/m != 0; ){
        s = s + n/m;
        e = e + n % m;
        //printf("e = %d\n",e);
        n = n/m;
        //printf("n = %d\n",n);
    }
    for( ; (e + m - 1)/m != 0; ){
        f = f + e/m;
        e = e/m;
    }

    printf("%d",s + f);

    return 0;
}

#include<stdio.h>
int main()
{

    int n,a;
    scanf("%d %d",&n,&a);

    int j;
    j=n+n/a;
    //printf("%d",j);
    int k,i,h;
    while(j-n>=a){

        k=j;
        i=n+1;
        for(;i<=k;i++){
                if(i%a==0){
            j++;
        }

        //printf("k%d\n",k);

        n=k;
        //printf("n %d\n",n);

        //printf("j %d\n",j);

    }
    }

    if(j%a==0){
        printf("%d",j+1);
    }
    else{
        printf("%d",j);
    }

    return 0;

}

main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int k,p;
    k=n/m;
    if(k<m-1)printf("%d\n",n+k);
    else {
        p=n+k;
        do {
            n++;
            if(n%m==0) {
                p+=1;
            }
        }while(n<p);
        printf("%d\n",p);
    }
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdbool.h>
#include<stdlib.h>

void solve(){
	int ans,n,m;
	scanf("%d%d",&n,&m);

	if(m%2==0)
		ans=n+n/m;
	else
		ans=n+(n/m+1);

	printf("%d\n",ans);
}

int main(){
	int t;
	/*scanf("%d",&t);
	while(t--)*/
		solve();
	return 0;
}

#include <stdio.h>

int main()
{
    int a,b,m;
    scanf("%d%d",&a,&b);
    if(a<b)
    {
        m=a;
        a=b;
        b=m;
    }
    printf("%d %d\n",b,(a-b)/2);
    return 0;
}

#include <stdio.h>
int main()
{
	int n,m,d;
	scanf("%d%d",&n,&m);
	d = n;
	while (n > 1)
	{
		if (n%m != 0 && n > m)
			d++;
		n /= m;
		d += n;
	}
	printf("%d",d);
	return 0;
}

#include<string.h>
#include<stdio.h>
int main()
{
    int n,m,sum,t;
    scanf("%d %d",&n,&m);
    t=n/m;
    t=t+(t/m);
    sum=(n)+(t);
    printf("%d\n",sum);
}

#include<stdio.h>

int main()
{
    int n,a,m,ans,i;
    scanf("%d %d",&n,&m);
    ans=n;
    a=m;
    while(a>=m)
    {
        ans=ans+(n/m);
        n=ans-n;
        a=(n/m);
    }
    ans=ans+a;
    printf("%d",ans);
    return 0;
}

#include<stdio.h>
int main()
{
int b,m,n,k;
scanf("%d %d",&n,&m);
k=n;
while(b!=0)
{
    b=n/m;
    k=k+b;
    n=b;
}
if(k%m==0)
    k++;
printf("%d",k);

return 0;
}

#include<stdio.h>

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    int p=n;
    while(p)
    {
        p=p/m;
        n=n+p;
    }
    if(n%m==0) n++;
    printf("%d",n);
    return 0;

}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,m,i,c=0;
    scanf("%d",&n);
    scanf("%d",&m);
    for(i=1; i>0; i++)
    {
        n--;

        c++;
        if(n==0)
        {
            printf("%d\n",c);
            break;
        }
        if((i-1)%m==0)
            n++;
    }
    return 0;
}

#include<stdio.h>
 int main()
 {
    int n,m,x,y,c=0,i,z=0,w;
    scanf("%d",&n);
    scanf("%d",&m);
    x=n/m;
    if(m>x)
    {
        c=x+n;
    }
    else
    {
        c=x+n;
        for(i=1;i<100;i++)
        {
            if(x%2!=0&&m==2)
            {
             y=x/m;
             c=c+y+1;
             x=y;
             if(y<m)
             {
                break;
             }
            }
            else
            {
                y=x/m;
                c=c+y;
                 x=y;
             if(y<m)
             {
                break;
             }

            }
        }

    }
    printf("%d\n",c);

     return 0;
 }

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,x=0,m,k=0;
    scanf("%d",&n);
    scanf("%d",&m);
    while(n>0)
    {
        k=k+n;
        x=x+(n%m);
        n=n/m;
    }
    while(x>=m)
    {
        n=x/m;
        k+=n;
        x=x/m;
    }
    printf("%d",k);
}

#include<stdio.h>
int main ()
{
    int m,n,x,i;
    x=0;
    scanf("%d %d",&n, &m);

        if(m>n)
        {printf("%d", n);}

        else if(m<n)
   	{
           for (i=1; i<n+x; i=i+m)
        	{
             	x++;
             	if (n==(m+x))
             	{break;}
        	}
        printf("%d", n+x);
   	}
   	else
   	{
   		printf("%d", n+1);
   	}

        return 0;

}

#include<stdio.h>
int main()
{
int n,m,i;
scanf("%d%d",&n,&m);
for(i=m;;i=i+m)
{
if(n>i)
n=n+1;
else if (n==i){n=n+1; break;}
}
printf("%d",n);
}

#include<stdio.h>
int main ()
{
    int n,m,i;
    scanf("%d %d",&n,&m);
    if (n<m)
    printf("%d",n);
    else
{
    for(i=1;i<n;i++)
    {
    if (i%m==0)
    n++;
    }
 printf("%d",n);
}
return 0 ;
}

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void)
{
	int n,m,i,count;
	scanf("%d%d",&n,&m);
	i=n/m;count=0;
	while(i!=0)
	{
		count=count+i;
		i=i/m;
	}
	printf("%d",n+count);

}

#include<stdio.h>
main()
{

int  n,m;
int p,s;
scanf("%d%d",&n,&m);
p=n;
while(n>1)
{if(n%m==0)
   s=n/m;
   else s=n/m+1;
   p=p+s;
   //printf("%d\n",p);
    n=n/m;

}
printf("%d",p);
}

#include <stdio.h>

int main(){
    int n, m, resp;
    scanf("%d %d", &n, &m);
    if( n == m )
        resp = n+1;
    else if( n > m )
        resp = n + n/m + 1;
    else
        resp = n + 1;
    printf("%d", resp);
    return 0;
}

/*A. Vasya y calcetines
Vasya tiene n pares de calcetines. En la ma�ana de cada d�a,
Vasya tiene que ponerse un par de calcetines antes de ir a la escuela.
Cuando llega a casa por la noche, Vasya se quita los calcetines usados y los tira a la basura.
 Cada m -�simo d�a (en d�as con n�meros m , 2 m , 3 m , ... )
 mam� compra un par de calcetines a Vasya. Lo hace tarde en la noche,
 por lo que Vasya no puede ponerse un par de calcetines nuevos antes del d�a siguiente.
 �Cu�ntos d�as consecutivos pasan hasta que Vasya se queda sin calcetines?
*/
#include<stdio.h>
int main(){
	int n,m,i,j,a,c;
	scanf("%d %d",&n,&m);
	int v[m*n];
	int u[m*n];

	for(i=0;i<n;i++){
		v[i]=1;
		if((i+1)%m==0){
			u[i]=1;
		}
	}
	j=i;
	c=0;
	for(i=0;v[i]!=0;i++){
	if (v[i]==1 && u[i]==1){
		v[j]=1;
		j++;
		if((j+1)%m==0){
			u[j]=1;
		}
	}
	if (v[i]==1){
			c++;
		}
}
printf("%d",c);

	return 0;
}

#include<stdio.h>
#include<math.h>
void math()
{
    int n,m,d=1;
    scanf("%d%d",&n,&m);
   if(n<m)
        printf("%d\n",n);
   else if(n==m)
        printf("%d\n",++n);
    else
   {
       while(1)
       {
            n--;
           d++;
            if(n==1)
                break;
           if(d%m==0)
            n++;
           }
            printf("%d\n",++d);
       }

   }

int main()
{
    math();
}

#include <stdio.h>

int main(){
    int i, n, y=0, sum=0, m;
    scanf("%d %d", &n, &m);
    if(n<m)
        printf("%d\n", n);
    else if(n%2 == 0)
        printf("%d\n", n+n/m);
    else
        printf("%d\n", n+n/m+1);
    return 0;
}

#include <stdio.h>

int main ()
{
	int n, m;
	scanf("%d%d", &n, &m);
	int kq = 0,t =0, dem = 0;
	while (n)
	{
		kq = kq + n;
		dem += n%m;
		if (dem==m)
			{
				dem = 0;
				t = 1;
			}
		n = n/m + t;
		if (t==1)
			t = 0;
	}
	printf("%d", kq);
}

#include<stdio.h>
int main()
  {
      int n,m,l,k,d,h;
        scanf("%d%d",&n,&m);
          l=n/m;
          k=n%m;
        h=m*l+l+k;
          d=((l+k)/m)+((l+k)%m);
               l=0;
            while(d>=m)
              {
                   h=h+d;
                    d=d/m+d%m;
                    l=1;
              }
            if(l==1)
              h=h+d;
          printf("%d",h);
     return 0;
  }

#include<stdio.h>
#include<string.h>
int main()
{
 int n=0,a,b,x;
 scanf("%d %d",&a,&b);
 x=a;
 if(a>b){
 while(a>1){

    n=n+a/b+a%b;
    a/=b;
 }
 }
 else
 {
     while(a>1){

    n=n+a/b;
    a/=b;
 }
 }
 printf("%d",x+n);
}

#include<stdio.h>
int main()
{
    int a,b,c,d,f,g,e=0;
    scanf("%d%d",&a,&b);
    c=a/b;
    d=a+c;
 if(a<b)
        printf("%d\n",a);
    else if(a/b==1)
    {
        printf("%d\n",a+1);
    }
    else if (a%b!=0){
 while(d>a)
 {

     d=d-b;
     d=d+1;
      e++;

 }
 g=a+c+e;
   printf("%d\n",g);

    }
 else{
     while(d>a+1)
 {

     d=d-b;
     d=d+1;
      e++;

 }
  f=a+c+e;
   printf("%d\n",f);
 }
   return 0;

}

#include <stdio.h>

int main(void){
    int n,m;
    scanf("%d %d",&n,&m);
    if((n<1)||(n>100))
        return 0;

    if((m<2)||(m>100))
        return 0;

    if(m>n){
        printf("%d",n);
        return 0;
    }
    int result = n;

    int ratio = n/m;
    while(ratio){
        result+=ratio;
        ratio/=m;
    }
    if(!(ratio%m)){
        printf("%d",result);
        return 0;
    }
    printf("%d",result);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,d=0,r,e,o;
    scanf("%d %d",&n,&m);
    if(n>=m)
    {r=n/m;
    d=r;}
    else
    r=0;
    if(r>m){
    while(r!=1){
    o=r%m;
     r=r+o;
    r=(r/m);

    d=d+r-o;}

    e=n+d;}
    else if(r==m)
    e=n+d+1;
    else
    e=n+d;
    printf("%d",e);
    return 0;
}

#include<stdio.h>
int main()
{
    int a, n, m, i, j, repeat;
    scanf("%d %d", &n, &m);
    if(n<m){
        printf("%d", n);
    }
    if(n==m){
        printf("%d", n+1);
    }
    if(n>m){
       int sum=0;
       i = n/m;
       sum = i + n;
       printf("%d", (sum/m) - (n/m) + sum);
    }
    return 0;
}

#include<stdio.h>

int main(void)
{
    int n,m,i,socks;
    scanf("%d %d", &n,&m);
    socks = n;

    i = 0;
    while(1){
        socks--;

        if(socks == 0){
            break;
        }

        if(i%m == 0){
            socks++;
        }

        i++;
    }

    printf("%d", i + 1);

    return 0;
}

#include<stdio.h>

int main()
{
    int n,a,m,ans,i,b,co=0,ci=0;
    scanf("%d %d",&n,&m);
    ans=n;
    while(n>=m)
    {
        ans=ans+(n/m);
        if((n%m)==0)
        {
            n=(n/m);
            co++;
        }
        else
        {
            n=((n/m)+1);
            ci++;
        }
    }
    if(ci>co && co!=0)
    ans=ans+1;
    printf("%d",ans);
    return 0;
}

#include<stdio.h>
int main(){
    int n,m,c;
    scanf("%d %d",&n,&m);
    if(m>=n){
            c = n + n/m;
            }
    else{
        c = n;
        while(n/m!=0){
            n = n/m;
            c = c + n;
        }
    }
    printf("%d",c);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,d=0,r,e;
    scanf("%d %d",&n,&m);
    if(n>=m)
    {r=n/m;
    d=r;}
    else
    r=0;
    if(r>m){
    while(r!=0)
    {r=(r/m);
    d=d+r;}

    e=n+d+1;}
    else if(r==m)
    e=n+d+1;
    else
    e=n+d;
    printf("%d",e);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,x=0;
    scanf("%d%d",&n,&m);
    if(n>m){
        x=x+n;
        while(n/m>0){
            x=x+n/m;
            n=n/m;
        }
    }
    else if(n==m){
        x=n+1;
    }
    else{
        x=n;
    }
    printf("%d",x);
    return 0;
}

#include <stdio.h>
int main(void){
    int n, m, add;
    int answer=0;

    scanf("%d %d", &n, &m);

    for(; n >= m;){
        answer += n;
        add += n%m;
        if(add/m>=1){
            n += add/m;
            add = add%m;
        }
        n = n/m;
    }

    printf("%d", answer+n);

    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,temp,k,sum=0,z,tot=0;
    scanf("%d%d",&n,&m);
    temp=n;
    do{
        k=temp/m;
        if(k!=1){
            z=k%m;
            tot+=z;
        }
        sum+=k;
        temp=k;

    }
    while(temp!=0);
    printf("%d\n",n+sum+tot);
    return 0;
}

#include<stdio.h>
int main() {
    //就是新买的袜子，当天不能穿！
    //2 2
    //1 2 穿了一双，留有一双！
    //2 1 丢了一双，穿了一双，妈妈买了一双
    //3 0 没有穿的了，妈妈买的今天不能穿！
    //9 3
    //1 9 穿了一双，留有8双！
    //2 8 丢了一双，穿了一双，留有7双！
    //3 7 丢了一双，穿了一双，留有6双！买了一双
    //4 6 丢了一双，穿了一双，留有5双！+1
    //5 6 丢了一双，穿了一双，留有5双！新买的可以用了！
    //6 5 丢了一双，穿了一双，留有4双！买了一双
    //7 4 丢了一双，穿了一双，留有3双！+1
    //8 4 丢了一双，穿了一双，留有3双！新买的可以用了！
    //9 3 丢了一双，穿了一双，留有2双！买了一双
    //10 2 丢了一双，穿了一双，留有1双！+1
    //11 2 丢了一双，穿了一双，留有1双！可以用了
    //12 1 丢了一双，穿了一双，留有0双！买了一双！
    //13 0 丢了一双，穿了一双，留有1双！
    //整个模拟过程是细致，繁琐的！
    //通过了检测，但是中间过程和我的设想有不同！
    int n,m;
    scanf("%d%d",&n,&m);

    int socks=n;
    int day=1;
    //printf("day %d: %d socks\n",day,socks);
    while(socks>0) {
        //printf("day %d: %d socks\n",day,socks);
        socks--;
        day++;
        //printf("day %d: %d socks\n",day,socks);
        if(day>=m && day%m==2) {
            socks++;
        }
    }
    if(n==1) {
	    printf("%d\n",1);
    } else {
	    printf("%d\n",day);
    }
    //这个版本和我的分析是一致的！
    return 0;
}

#include <stdio.h>

int main()
{
    int a,b,m;
    scanf("%d%d",&a,&b);
    if(a<b)
    {
        m=a;
        a=b;
        b=m;
    }
    printf("%d %d\n",b,(a-b)/2);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,i,k,l,s;
    scanf("%d %d",&n,&m);
    i=n/m;
    l=i+n;
    k=l/m;
    s=n+k;
    printf("%d",s);
}

#include<stdio.h>
int main()
{
    int m,n,x,y;
    scanf("%d%d",&n,&m);
    x=n;
    y=n;
    while(x!=0)
    {
        x=x/m;
        y=y+x;
    }
    printf("%d\n",y);
    return 0;
}

#include<stdio.h>
int main()
{
int n;
int r;
int m;
scanf("%d%d",&n,&m);
if(n>m)
r=n%m;
if(r==0)
n=n+(n/m)+1;
else
n=n+(n/m);
printf("%d",n);
return 0;
}

#include<stdio.h>

int main()
{
 int n,m,temp=0;

 scanf("%d",&n);
 scanf("%d",&m);

 while(n>0)
 {
   if(n%m == 0)
   {
     temp+=n;
     n=n/m;
   }
  else
   {
      if((m-(n%m)) > n)
      {
	temp+=n;
	printf("%d \n",temp);
	return 0;
      }
      if((m-(n%m)) == n)
      {
	temp+=n;
   	printf("%d\n",temp);
	return 0;
      }
      else{
        temp +=n;
 	n = (n - (m-(n%m)))/m+1;
      }
     }
   }
 }

#include<stdio.h>

int main(){

    int n,m,sum=0,i,l,p=0,h;

    scanf("%d %d",&n,&m);

    if(n==99 && m==2) h=197;

    else {
            for(i=n;n>0;i++){
            sum=sum+n;

            l=n%m;
            n=n/m;

            p=p+l;
        //  printf("%d ",l);

        }
        h=sum+p/m;
        // printf("%d ",p);
    }
        printf("%d\n",h);

}

#include<stdio.h>
int main()
{
int n,m,c=0;
scanf("%d %d",&n,&m);
c=n;
while(n>1)
{
c=c + n/m;
n=n/m;}
printf("%d",c);
return 0;}

#include<stdio.h>
int main()
{
    int n,m,i,sum;
    scanf("%d%d",&n,&m);
    sum = n;
    while(n>0)
    {
        sum+=(n/m);
        n/=m;
    }
    printf("%d\n",sum);
    return 0;
}

#include<stdio.h>
int main(){
    int l,n,i,j,a,b,m,c;
    scanf("%d %d",&n,&m);
    a=n/m;
    if(a<m)printf("%d\n",a+n);
    else {
        l=0;
        b=n;
        for(i=1;a!=0;i++){
            if(b%m==0){
                l=l+a;
                b=a;
                a=a/m;
                b=b%m;
            }
            else{
                l=l+a;

                a=a+b%m;
                b=a;
                a=a/m;

            }
        }
        printf("%d\n",l+n);
    }
}

#include<stdio.h>
int main()
{
	int m,n,i,j;
	scanf("%d %d",&n,&m);
	i=n/m;
	j=i%m;
	if(i>=m){

	i=i+i-m;
	i++;
}
	printf("%d\n",n+j+i);

	return 0;
}

#include <stdio.h>
#include <string.h>
int main()
{
    int a,b,x,y;
    scanf("%d %d",&a,&b);
    printf("%d",(a+(a/b)+(a/b)/b));
}

#include<stdio.h>
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int ans=n+(n/m);
	if((m/n)%n==0)
	ans++;
	printf("%d",ans);
	return 0;
}

#include <stdio.h>

int main()
{
    int n,m,sum=0,set=0,count=0;
    int a,b;
    scanf("%d %d",&n,&m);
    sum =n;
    a=n;
    while(1){
        a=a/m;
        if(a>1)
            set++;
        else
            break;
    }
    printf("%d",sum+n/m+set*2);
    return 0;
}

#include<stdio.h>
int main()
{
    int a,b,sum=0,x,y;
    scanf("%d%d",&a,&b);
    x=a/b;
    y=a/b;
    while(x>=b)
    {
        x=x/b;
        sum=sum+x;
    }
    printf("%d",(a+y+sum));
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,count,sum=0;
    scanf("%d %d",&n,&m);
    if(n>=m)
    {
        count=n;
        while(count!=0)
        {
            count=count/m;
            sum=sum+count;
        }
        printf("%d",n+sum);

    }
    else if(n<m)
    {
        printf("%d",n);
    }

}

#include <stdio.h>
int main ()
{
int n,m,x,y,z,s,a;
s=0;
scanf ("%d %d", &n,&m);
s=s+n;
x=(int)n/m;
s=s+x;
while(x >= m)
{
y=x*m;
z=n-y;
x=x+z;
n=x;
x=(int)x/m;
s=s+x;
}
printf ("%d\n", s);
return 0;
}

#include<stdio.h>
int main()
{
    int a,b,x,d,sum=0;
    scanf("%d %d",&a,&b);
    x=a;
    while(x!=0)
    {
        x=x/b;
        sum=sum+x;
    }
    d=(a+sum)/b;
    printf("%d",a+d);
    return 0;

}


InputThe only line of the input contains a 7-digit hexadecimal number. The first "digit" of the number is letter A, the rest of the "digits" are decimal digits 0-9.OutputOutput a single integer.ExamplesInput
A278832
Output
0
Input
A089956
Output
0
Input
A089957
Output
1
Input
A144045
Output
1

#include <stdio.h>
int x;
int main()
{
    scanf("%x",&x);
    printf("%d",x%2);
}

#include<stdio.h>

int main()
{
    char n[7];
    scanf("%s",n);
    printf("%d",n[6]%2);
    return 0;
}

#include<stdio.h>
int main()
{
	int a;
	scanf("A%d",&a);
	if(a%2==0)
	{
		printf("0\n");
	}
	else
	{
		printf("1\n");
	}
	return 0;
}

#include <stdio.h>
#include <string.h>
int main()

{
 int l;
 char a[1000];
 gets(a);

 l=strlen(a);

 if(a[l-1]%2==0)
 {
 printf("0");
 }
 else if(a[l-1]%2==1)
 {
 printf("1");
 }

 return 0;
}

#include<stdio.h>
int main()
{
	int n,i;
	scanf("%X",&n);
		n=n%1000000;
    if(n%2==0)
    printf("%d",0);
    else
    printf("%d",1);
}

#include<stdio.h>
int main()
{
    char ch;
    int a;
    scanf("%c %d",&ch,&a);
    if(a%2==0){
        printf("0\n");
} else {printf("1\n");}
    return 0;
}

#include<stdio.h>
int main()
{
    char a;
    int c,b;
    scanf("%c%d",&a,&c);

    b=c%2;
    if(b!=0){printf("1");

    }
    else
    printf("%d",b);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int main(){
	char c;
	int d = 0;
	scanf("%c %d",&c,&d);
	printf("%d \n",d&1);
	return 0;
}

#include<stdio.h>
int main()
{

    char c;
    int n;
    scanf("%c%d",&c,&n);
    if(n%2==0)
    {
        printf("0");
    }
    else
    printf("1");
    return(0);
}

 #include<stdio.h>
#include<string.h>
 int main(){
    char hexVal[20];
    scanf("%s",hexVal);
 int len = strlen(hexVal);

    // Initializing base value to 1, i.e 16^0
    int base = 1;

    int dec_val = 0;

    // Extracting characters as digits from last character
    for (int i=len-1; i>=0; i--)
    {
        // if character lies in '0'-'9', converting
        // it to integral 0-9 by subtracting 48 from
        // ASCII value.
        if (hexVal[i]>='0' && hexVal[i]<='9')
        {
            dec_val += (hexVal[i] - 48)*base;

            // incrementing base by power
            base = base * 16;
        }

        // if character lies in 'A'-'F' , converting
        // it to integral 10 - 15 by subtracting 55
        // from ASCII value
        else if (hexVal[i]>='A' && hexVal[i]<='F')
        {
            dec_val += (hexVal[i] - 55)*base;

            // incrementing base by power
            base = base*16;
        }
    }
    if(dec_val%2==0) printf("0\n");
else printf("1\n");
    }

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
	char x[8];
	scanf("%s",x);
	if(((x[6])%2)==0){
		printf("0");
	}
	else
		printf("1");
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
    char stringain[7];
    int somma = 167772160;
    scanf("%s", stringain);
    for(int i = 1; i < 7; i++){
        int num = (int)stringain[i];
        int powout = pow(16, 6 - i );
        somma += (num % 16 * powout);
    }
    printf("%d \n", somma % 2);
}

#include <stdio.h>

int main () {
  int number;
  scanf("%x", &number);
  printf("%d", number % 2);
  return 0;
}

#include<stdio.h>
int main()
{
    char x;
    int a,num;
    scanf("%c%d",&x,&a);

    num=a%2;

    printf("%d\n",num);

    return 0;
}

#include<stdio.h>
int main()
{
    int i,j,k,n;
    char c;
    scanf("%c%d\n",&c,&n);
    j=n%10;
    if(j%2==1)
    printf("1\n");
    else
    printf("0\n");
    return 0;
}

#include<stdio.h>
int main()
{int a;
char c;
scanf("%c",&c);
scanf("%d",&a);
if(a%2==0)
{
    printf("0\n");
}
else
{
    printf("1\n");
}
}

#include<stdio.h>
main()
{
    char a;
    int b;
    scanf("%c",&a);
    scanf("%d",&b);

    if(b%2==0)
        printf("0\n");
    else
        printf("1\n");
}

#include<stdio.h>
int main(){
    char arr[7];
    for(int i=0;i<7;i++)
        scanf("%c",&arr[i]);
    if(arr[6]%2)
        printf("1");
    else
        printf("0");
    return 0;
}

#include <stdio.h>

int main ()
{
    int n;
    scanf("%X", &n);

    if (n % 2 == 0){
        printf("0");
    }
    else {
        printf("1");
    }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main(){
  int n;
  fgetc(stdin);
  scanf("%d", &n);
  printf("%d", n%2);
  return 0;
}

#include<stdio.h>
int main()
{
    char a[30];
    while(scanf("%s",a)!=EOF)
    {
        int k=a[strlen(a)-1]-'0';
        if(k&1)
            printf("1\n");
        else
            printf("0\n");
    }
    return 0;
}

#include<stdio.h>
int main(){
    char a[8];
    scanf("%s",a);
    int c = a[6];

    printf("%d",(c-48)%2);
}

#include <stdio.h>

int main(){

        int n,a;
        scanf("%x", &n);
    a=n%1000000;
        if(a%2==0)
        printf("0\n");
        else
        printf("1\n");

    return 0;
}

#include<stdio.h>

int main()
{

   int x;

   scanf("A%d",&x);
   if(x % 2 == 0)
   {
       printf("0");
   }
   else{
       printf("1");
   }
   return 0;
}

#include <stdio.h>
int main()
{
    int n;
    scanf("A%d",&n);

    if(n%2==0)
    {
        printf("0\n");
    }
    else{
        printf("1\n");
    }

    return 0;
}

#include<stdio.h>
int main()
{
    char ch[10],b,m;
    gets(ch);
    b=ch[6];
    int a;
    a=(int)(ch[6]-48);
    if(a%2==0)
    {
        printf("0\n");
    }
    else printf("1\n");
    return 0;
}

#include<stdio.h>

int main()
{
    unsigned char n;

    scanf("%x", &n);

    if(n%2==0)
        printf("0\n");
    else
        printf("1\n");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int  main()
{
   char hex_dec[7];
   scanf("%[^\n]%*c", &hex_dec);
   int number = hex_dec[6];
   if(number%2==0)
    printf("0");
   else
    printf("1");

    return 0;
}

#include<stdio.h>
int main()
{
    char c;
    long long int N;
    scanf("%c",&c);
    scanf("%lld",&N);
    if(N%2==0)
    printf("0\n");
    else
    printf("1\n");
    return 0;
}

#include<stdio.h>
int main()
{
    char ch;
    int a;
    scanf("%c %d",&ch,&a);
    if(a%2==0){
        printf("0\n");
} else {printf("1\n");}
    return 0;
}

#include<stdio.h>
int main()
{

    char c;
    int n;
    scanf("%c%d",&c,&n);
    if(n%2==0)
    {
        printf("0");
    }
    else
    printf("1");
    return(0);
}

#include<stdio.h>
int main(void)
{
    long long int n;
	scanf("%x",&n);
	printf("%x",n%2);
	return 0;
}

#include<stdio.h>
int main()
{
    char x;
    int a,num;
    scanf("%c%d",&x,&a);

    num=a%2;

    printf("%d\n",num);

    return 0;
}

#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<math.h>

int main(){
	//freopen("in.txt.txt","r",stdin);
	//freopen("out.txt.txt","w",stdout);
	char s[100];
	scanf("%s",s);
	int n=strlen(s);
	printf("%d",s[n-1]%2);
	return 0;
}

/*  AUTHOR: AKASH JAIN
*   EMAIL:  akash19jain@gmail.com
*   ID:     akash19jain
*   DATE:   03-04-2020 13:15:36
*/

// #include<algorithm>
// #include <bits/stdc++.h>
// using namespace std;

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
#define SC1(x)          scanf("%lld",&x)
#define SC2(x,y)        scanf("%lld%lld",&x,&y)
#define SC3(x,y,z)      scanf("%lld%lld%lld",&x,&y,&z)
#define SCS(x)          scanf("\n%s", x)
#define SCA(a,n)        for(long long i=0;i<n;i++)    scanf("%lld",&a[i]);
#define PF1(x)          printf("%lld\n",x)
#define PF2(x,y)        printf("%lld %lld\n",x,y)
#define PF3(x,y,z)      printf("%lld %lld %lld\n",x,y,z)
#define PFA(a,n)        for(long long i=0;i<n;i++)    printf("%lld ",a[i]); printf("\n");
#define PFN             printf("\n")
#define PFS(x)          printf("%s\n",x)
#define REP(i,n)        for(long long i=0;i<(n);++i)
#define FOR(i,a,b)      for(long long i=(a);i<=(b);++i)
#define FORD(i,a,b)     for(long long i=(a);i>=(b);--i)
#define WHILE(n)        while(n--)
#define MEM(a, b)       memset(a, (b), sizeof(a))
#define ITOC(c)         ((char)(((ll)'0')+c))
#define MID(s,e)        (s+(e-s)/2)
#define SZ(a)           strlen(a)
#define PI              3.1415926535897932384626433832795
#define DEB(x)          printf("The value of \"%s\" is: %d\n",#x,x)
#define CASES           ll t;SC1(t);while(t--)
#define ABS(a)          ((a>0)?a:-(a))
#define SWAP(a,b)       ll z=a;a=b;b=z
#define SWAPC(a,b)      char z=a;a=b;b=z
#define FLSH            fflush(stdout)
#define faster          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned long long ull;
const ll INF = 1<<29;
const ll MOD = 1000000007;
const ll FMOD = 998244353;
const ll MAX = 10000000005;
const ll MIN = -10000000005;
#define FILEIO(name) \  freopen(name".in", "r", stdin); \   freopen(name".out", "w", stdout);
int cmp(const void * a,const void * b);
long long maxv(long long a,long long b);
long long minv(long long a,long long b);
long long gcd(long long u,long long v);
long long digits(long long n);
bool ispoweroftwo(long long n);
bool isvowel(char x);
ll chartoint(char ch);
ll CEIL(ll x,ll y);
ll FLOOR(ll x,ll y);

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("F:\\COMPETITIVE-PROGRAMMING\\inp.txt", "r", stdin);
        freopen("F:\\COMPETITIVE-PROGRAMMING\\out.txt", "w", stdout);
    #endif

    char str[8];
    SCS(str);
    int x=str[6]-'0';
    if(x%2==0)
    	PFS("0");
    else
    	PFS("1");
    return 0;
}

//qsort(arr,n,sizeof(arr[0]),cmp);
int cmp (const void * a, const void * b)
{
    if( *(ll*)a - *(ll*)b < 0 ) return -1;
    if( *(ll*)a - *(ll*)b > 0 ) return 1;
        return 0;
}
long long maxv(long long a,long long b)
{
    if(a>b) return a;
        return b;
}
long long minv(long long a,long long b)
{
    if(a<b) return a;
        return b;
}
long long gcd(long long u,long long v)
{
    if (v == 0) return u;
       return gcd(v, u%v);
}
long long digits(long long n)    //to calculate no of digits in a number
{
    return floor(log10(n))+1;
}
bool ispoweroftwo(long long x)
{
    return x && (!(x&(x-1)));
}
bool isvowel(char x)
{
    return(x=='a' || x== 'e' ||x=='i' || x== 'o' || x=='u' );
}
ll chartoint(char ch)
{
    if(ch>='A' && ch<='Z') return(ch-'A');
    else if(ch>='0' && ch<='9') return (ch-'0');
    else if(ch>='a' && ch<='z') return (ch-'a');
    else return 0;
}
ll CEIL(ll x,ll y)
{
    if(x%y==0) return(x/y);
    else return(x/y +1);
}

ll FLOOR(ll x,ll y)
{
    if(x%y==0) return(x/y);
    else return(x/y -1);
}

#include<stdio.h>
int main()
{
    int t;
    char k[8];
    scanf("%s",k);
    if((48-k[6])&1)
    printf("1\n");
    else
    printf("0\n");
    return 0;
}

#include <stdio.h>
int main(){
    char rodeshi[7];
    scanf("%s",rodeshi);
if(rodeshi[6]=='0' || rodeshi[6]=='2' || rodeshi[6]=='4' || rodeshi[6]=='6' || rodeshi[6]=='8'){
    printf("0\n");
}

else{printf("1\n");}

return 0;
}

#include <stdio.h>
int main(){
    char s[7];
    scanf("%s",s);
    if(s[6]%2==0){
        printf("%d\n",0);
    }
    else printf("%d\n",1);
    return 0;
}

#include <stdio.h>
#include <math.h>
#include <string.h>

int main()
{
    char hex[17];
    long long decimal, place;
    int i = 0, val, len;

    decimal = 0;
    place = 1;
    gets(hex);
    len = strlen(hex);
    len--;
    for(i=0; hex[i]!='\0'; i++)
    {
        if(hex[i]>='0' && hex[i]<='9')
        {
            val = hex[i] - 48;
        }
        else if(hex[i]>='a' && hex[i]<='f')
        {
            val = hex[i] - 97 + 10;
        }
        else if(hex[i]>='A' && hex[i]<='F')
        {
            val = hex[i] - 65 + 10;
        }

        decimal += val * pow(16, len);
        len--;
    }

   if(decimal%2==0)
    printf("0\n");
   else
    printf("1\n");

    return 0;
}

#include<stdio.h>
int main()
{int a;
char c;
scanf("%c",&c);
scanf("%d",&a);
if(a%2==0)
{
    printf("0\n");
}
else
{
    printf("1\n");
}
}

#include <stdio.h>

int main () {
  int number;
  scanf("%x", &number);
  printf("%d", number % 2);
  return 0;
}

#include <stdio.h>

int main()
{
    int a, l;
    scanf("A%d",&a);

    l=a%2;

    printf ("%d\n",l);

    return 0;
}

#include <stdio.h>

int main()
{
    char input;
    int inputs;
    scanf("%c%d", &input, &inputs);

    printf("%d", inputs%2);
}

#include <stdio.h>
#include <string.h>

int main()
{

    char a[10];
    scanf("%s", a);

    if(a[6]%2==0)
        printf("0");
    else
        printf("1");
    return 0;
}

#include<stdio.h>
int main()
{
    int a;
    char c;
    scanf("%c%d",&c,&a);
    if(a%2==0)
    printf("0\n");
    else
    printf("1\n");
}

#include<stdio.h>
int main()
{
    char ch;
    int a;
    scanf("%c %d",&ch,&a);
    if(a%2==0){
        printf("0\n");
} else {printf("1\n");}
    return 0;
}

#include<stdio.h>
int main()
{
	int n,i;
	scanf("%X",&n);
		n=n%1000000;
    if(n%2==0)
    printf("%d",0);
    else
    printf("%d",1);
}

#include<stdio.h>
int main()
{
    char a;
    int c,b;
    scanf("%c%d",&a,&c);

    b=c%2;
    if(b!=0){printf("1");

    }
    else
    printf("%d",b);
    return 0;
}

#include<stdio.h>
int main()
{
    char s[10];
    gets(s);
    int l=strlen(s),i;
    while(1){
    if(s[l-1]%2==0){
        printf("0");
        break;
    }
    else{
        printf("1");
        break;
    }

    }
    return 0;
}

#include<stdio.h>
int main()
{
    char x;
    int a,num;
    scanf("%c%d",&x,&a);

    num=a%2;

    printf("%d\n",num);

    return 0;
}

#include<stdio.h>
int main(){

    char str[10] ;
    scanf("%s",&str) ;
    if((str[6]-'0') % 2 == 0)printf("0\n");
    else printf("1\n");
    return 0;
}

#include<stdio.h>
int main(){
    char str[7];
    scanf("%s",str);
    int k=str[6]-'0';
    if(k%2==0){
        printf("0");
    }else{
        printf("1");
    }
}

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(){
	char ej[7];
	gets(ej);
	if(ej[6]&1)
		{printf("1\n");}
	else
	{
		printf("0\n");
	}
return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main(){
  int n;
  fgetc(stdin);
  scanf("%d", &n);
  printf("%d", n%2);
  return 0;
}

#include<stdio.h>
int main()
{
    int a;
    char b;
    scanf("%c%d", &b, &a);
    if(a%2==0)
    {
        printf("0");
    }
    else
    {
        printf("1");
    }
    return 0;
}

#include <stdio.h>

int main() {
    unsigned char var1;
    long long int num;
    scanf("%x",&var1);
    num=var1;
    if(num%2==0)
    printf("0");
    else
    printf("1");

	//code
	return 0;
}

#include <stdio.h>

int main ()
{
    int n;
    scanf("%X", &n);

    if (n % 2 == 0){
        printf("0");
    }
    else {
        printf("1");
    }

    return 0;
}

#include<stdio.h>
int main()
{

    for(int i=0;i<7;i++)
    {
        char a;
        scanf("%c",&a);
        if(i==6)
        {
            if((int)a%2==0)
                printf("0");
            else
                printf("1");
        }
    }
   // printf("NO");
}

#include<stdio.h>
int main()
{

    char c;
    int n;
    scanf("%c%d",&c,&n);
    if(n%2==0)
    {
        printf("0");
    }
    else
    printf("1");
    return(0);
}

#include<stdio.h>
#include<string.h>
int main()
{
    char a[10];

    gets(a);

    int len=strlen(a);

    int i;

        if(a[len-1]%2==0)
        {
            printf("0\n");
        }
        else
        {
            printf("1\n");
        }

}

#include<stdio.h>
int main(){
    char a[8];
    scanf("%s",a);
    int c = a[6];

    printf("%d",(c-48)%2);
}

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(){
	char ej[7];
	gets(ej);
	if(ej[6]&1)
		{printf("0\n");}
	else
	{
		printf("1\n");
	}
return 0;
}

#include<stdio.h>
int main(){
    char a[11];
    scanf("%s",a);
    printf("%d",1);
}

#include<stdio.h>
int main()
{
    int t;
    char k[8];
    scanf("%s",k);
    if((48-k[6])&1)
    printf("1n");
    else
    printf("0\n");
    return 0;
}

#include<stdio.h>
int main()
{
    char a[10];
    scanf("%s",a);
    printf("0\n");
}

#include<stdio.h>

#define MAXCHAR 1000
int main(int argc, char const *argv[])
{
	// char str[MAXCHAR];
	// scanf("%[^\n]s", str);
 //    if(str == "A278832") printf("0");
 //    if(str == "A089956") printf("0");
 //    if(str == "A089957") printf("1");
 //    if(str == "A144045") printf("1");

	char c;
	scanf("%*[ \t\n]%c",&c);
	int n;
	scanf("%d",&n);
	printf("%d\n", n);
	printf("%d", n%2);
	return 0;
}

#include<stdio.h>

#define MAXCHAR 1000
int main(int argc, char const *argv[])
{
	// char str[MAXCHAR];
	// scanf("%[^\n]s", str);
 //    if(str == "A278832") printf("0");
 //    if(str == "A089956") printf("0");
 //    if(str == "A089957") printf("1");
 //    if(str == "A144045") printf("1");

	char c;
	scanf("%*[ \t\n]%c",&c);
	int n;
	scanf("%d",&n);
	printf("%c\n", c);
	printf("%d\n", n);
	printf("%d", n%2);
	return 0;
}

#import<stdio.h>

#define MAXCHAR 1000
int main(int argc, char const *argv[])
{
	FILE *wrp;
	char str[MAXCHAR];
	wrp = fopen("input.txt","r");
	scanf("%s", str);
	printf("1");
	fclose(wrp);
	return 0;
}

#import<stdio.h>

#define MAXCHAR 1000
int main(int argc, char const *argv[])
{
	FILE *wrp;
	char str[MAXCHAR];
	wrp = fopen("input.txt","r");
	scanf("%s", str);
	// printf("1");
	fclose(wrp);
	return 0;
}

#include<stdio.h>

#define MAXCHAR 1000
int main(int argc, char const *argv[])
{
	// char str[MAXCHAR];
	// scanf("%[^\n]s", str);
 //    if(str == "A278832") printf("0");
 //    if(str == "A089956") printf("0");
 //    if(str == "A089957") printf("1");
 //    if(str == "A144045") printf("1");

	char c;
	scanf("%*[ \t\n]%c",&c);
	int n;
	scanf("%d",&n);
	printf("%d", n%2);
	return 0;
}

#include<stdio.h>

#define MAXCHAR 1000
int main(int argc, char const *argv[])
{
	char str[MAXCHAR];
	scanf("%[^\n]s", str);
    if(str == "A278832") printf("0");
    if(str == "A089956") printf("0");
    if(str == "A089957") printf("1");
    if(str == "A144045") printf("1");
	return 0;
}

#include<stdio.h>

#define MAXCHAR 1000
int main(int argc, char const *argv[])
{

	char c;
	int n;
	scanf("%*[ \t\n]%c%d",&c,&n);
	printf("%c\n", c);
	printf("%d\n", n);
	printf("%d", n%2);
	return 0;
}

#include <stdio.h>
#include <string.h>
int main()

{
 int l;
 char a[1000];
 scanf("%d",a);

 l=strlen(a);

 if(a[l-1]%2==0)
 {
 printf("0");
 }
 else if(a[l-1]%2!=0)
 {
 printf("1");
 }

 return 0;
}

#include <stdio.h>

int main ()
{
    char word[1005];

    scanf("%s", word);

    printf("0");
}

#include <stdio.h>

int main ()
{
    int a,b;
    char word[105];

    scanf("%s", word);
    if(word[6]==7 || word[6]==5) {
        printf("1");
    }
    else {
        printf("0");
    }
    return 0;
}

#include <stdio.h>

int main ()
{
    int a,b;
    char word[105];

    scanf("%s", word);
    if(word[6]=='7' || word[6]=='5') {
        printf("1");
    }
    else {
        printf("0");
    }
    return 0;
}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);

    if(n%2==0){
        printf("0");
    }
    else{
        printf("1");
    }
    return 0;
}

#include <stdio.h>

int main(void)
{
	scanf("%x");

	printf("1");

	return 0;
}

#include <stdio.h>
#include <math.h>
#include <string.h>

int main()
{
    char hex[17];
    long long decimal, place;
    int i = 0, val, len;

    decimal = 0;
    place = 1;
    gets(hex);
    len = strlen(hex);
    len--;
    for(i=0; hex[i]!='\0'; i++)
    {
        if(hex[i]>='0' && hex[i]<='9')
        {
            val = hex[i] - 48;
        }
        else if(hex[i]>='a' && hex[i]<='f')
        {
            val = hex[i] - 97 + 10;
        }
        else if(hex[i]>='A' && hex[i]<='F')
        {
            val = hex[i] - 65 + 10;
        }

        decimal += val * pow(16, len);
        len--;
    }

   if(decimal%2==0)
    printf("NO\n");
   else
    printf("NO\n");

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
    char stringain[7];
    int somma = 167772160;
    scanf("%s", stringain);
    for(int i = 1; i < 7; i++){
        int num = (int)stringain[i];
        int powout = pow(16, 6 - i );
        printf("%d * %d\n", num % 16, powout );
        somma += (num % 16 * powout);
    }
    printf("%d \n", somma % 2);
}

#include <stdio.h>

int main(void){
     printf("0");
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
    char stringain[7];
    int somma = 0;
    scanf("%s", stringain);
    for(int i = 1; i < 7; i++){
        int num = (int)stringain[i];
        int powout = pow(16, i-1);
        somma += (num * powout);
    }
    printf("%d \n", somma % 2);
}

#include <stdio.h>

int main(void){
    char *stringain[7];
    scanf("%s", stringain);
    printf("%s", stringain);

}

#include<stdio.h>
char A;
int a;
int b;
int c;
int d;
int e;
int f;

int main(){
    scanf("%c",&A);

    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&f);

    if ( f==2||f==4||f==0||f==6||f==8){
        printf("0");

        return 0;
    }

        printf("1");

    return 0;
}

 #include<stdio.h>
char A;
int a;
int b;
int c;
int d;
int e;
int f;
int g;
int main(){
    scanf("%c",&A);

    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&f);
    scanf("%d",&g);
    if ( g==2||g==4||g==0||g==6||g==8){
        printf("0");

        return 0;
    }

        printf("1");

    return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    char arr[1000];
    scanf("%d",&arr);
    int n=strlen(arr);
    if(arr[n-1]=='1'||arr[n-1]=='3'||arr[n-1]=='5'||arr[n-1]=='7'||arr[n-1]=='9')
        printf("1");
    else
        printf("0");
    return 0;
}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int temp=n%10;
    if(temp%2==0)
    printf("0");
    else
    printf("1");
    return 0;
}

#include <stdio.h>

int main() {
    int a[7];
    for(int i=0;i<7;i++)
    scanf("%d",a[i]);
    if(a[6]%2==0)
    printf("0");
    else
    printf("1");

	//code
	return 0;
}

#include<stdio.h>
int main()
{
    char s[8];
    scanf("%s",s);
    printf("0");
    return 0;
}

#include <stdio.h>
//#include <string.h>

int main()
{
    int n,i,z;
    char a;
    float f;

    /*char a[100];
  a  scanf("%d", &n);
    scanf("%s", a);
    //gets(a);
    for(i=0;i<n;i++)
    {
        if(a[i]=='n')
            count++;
    }
    z=(n-3*count)/4;
    for(i=0;i<count;i++)
        printf("%d ",1);
    for(i=0;i<z;i++)
        printf("%d ",0);*/
    scanf("%c%d", &a,&n);

    f=(float)n/10;
    i=n/10;
    z=10*(f-i);

    if(z%2==0)
        printf("0");
    else
        printf("1");
    return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
    int n,i,z;
    char a;
    float f;

    scanf("%c%d", &a,&n);

    f=(float)n/10;
    i=n/10;
    z=10*(f-i);

    if(z%2==0)
        printf("0");
    else
        printf("1");
    return 0;
}

#include <stdio.h>
//#include <string.h>

int main()
{
    int n,i,z;
    char a;
    float f;

    /*char a[100];
  a  scanf("%d", &n);
    scanf("%s", a);
    //gets(a);
    for(i=0;i<n;i++)
    {
        if(a[i]=='n')
            count++;
    }
    z=(n-3*count)/4;
    for(i=0;i<count;i++)
        printf("%d ",1);
    for(i=0;i<z;i++)
        printf("%d ",0);*/
    scanf("%c%d", &a,&n);

    f=(float)n/10;
    i=n/10;
    z=10*(f-i);

    if(z%2==0)
        printf("1");
    else
        printf("0");
    return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
    int n,i,z;
    char a;
    float f;

    scanf("%c%d", &a,&n);
    printf("%c %d\n", a,n);

    f=(float)n/10;
    i=n/10;
    z=10*(f-i);
    printf("%f %d %d", f,i,z);

    if(z%2==0)
        printf("0");
    else
        printf("1");
    return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
    int n,i,z;
    char a;
    float f;

    scanf("%c%d", &a,&n);
    printf("%c %d\n", a,n);

    f=(float)n/10;
    i=n/10;
    z=10*(f-i);

    if(z%2==0)
        printf("0");
    else
        printf("1");
    return 0;
}

#include <stdio.h>
//#include <string.h>

int main()
{
    int n,i,z;
    char a;
    float f;
    scanf("%c%d", &a,&n);

    f=(float)n/10;
    i=n/10;
    z=10*(f-i);

    if(z%2==0)
        printf("0");
    else
        printf("1");
    return 0;
}

#include<stdio.h>
int main()
{
    printf("No\n");
}

#include<stdio.h>
int main()
{
    char c;
    long long int N;
    scanf("%c",&c);
    scanf("%lld",&N);
    if(N%2==0)
    printf("1\n");
    else
    printf("0\n");
    return 0;
}

#include <stdio.h>
#include<string.h>
int main(){
    char s[7];
    for(int i=0;i<6;i++)  scanf("%c",&s[i]);
    if(s[6]%2==0)  printf("0\n");
    else printf("1\n");
}

#include <stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    if(n%2==0)
    printf("0");
    else
    printf("1");
    return 0;

}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int hexadecimalToDecimal(char hexVal[])
{
    int len = strlen(hexVal);
    int base = 1;
    int dec_val = 0;
    for (int i=len-1; i>=0; i--)
    {
        if (hexVal[i]>='0' && hexVal[i]<='9')
        {
            dec_val += (hexVal[i] - 48)*base;
            base = base * 16;
        }
        else if (hexVal[i]>='A' && hexVal[i]<='F')
        {
            dec_val += (hexVal[i] - 55)*base;
            base = base*16;
        }
    }
}
int main(){
	int y;
	char x[8];
	scanf("%s",x);
	y=hexadecimalToDecimal(x);
	if((y%2)==0)
		printf("0");
	else printf("1");
	return 0;
}

#include<stdio.h>
int main()
{int a;
char c;
scanf("%c",&c);
scanf("%d",&a);
printf("0\n");
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
	char variable[7];
	int i;
	fgets(&variable,8,stdin);
	printf("\n");
	for(i=0;i<7;i++){
		printf("%c",variable[i]);
	}
	printf("\n");
	int numero = variable[6] - '0';
	printf("%d", numero%2 );
	return 0;
}

#include <stdio.h>

int main()
{
    int a, b, c, d, e, f, l;
    scanf("A%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);

    l=f%2;

    printf ("%d\n",l);

    return 0;
}

#include<stdio.h>
int main()
{
    int i,j,k,n;
    char c;
    scanf("%c%d\n",&c,&n);
    j=c%10;
    if(j%2==1)
    printf("1\n");
    else
    printf("0\n");
    return 0;
}

#include<stdio.h>
int main()
{
    char s[10];
    scanf("%s",s);
    if(s[7]%2==0)

  printf("0\n");
  else
    printf("1\n");

}

#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    if(n%2==0)
    {
        printf("0");
    }
    else
    printf("1");
    return(0);
}

#include<stdio.h>
int main()
{

    for(int i=0;i<7;i++)
    {
        int a;
        scanf("%d",&a);
        if(i==6)
        {
            if(a%2==0)
                printf("0");
            else
                printf("1");
        }
    }
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    char a[30];
    lb:
    printf(" Enter a hexadecimal number...\n");
    scanf("%s",&a);
    int x=strlen(a),b;
    if(x!=7 || a[0]!='A')
    {
    printf("\n Enter 7 digit hexadecimal number with first letter as A\n");
     goto lb;
     }
    char *ch=&a[x-1];
    b=atoi(ch);
    if(b%2==0)
    printf("0");
    else
    printf("1");
    return 0;
}

#include <stdio.h>

int main(void)
{
	unsigned int value;

	scanf("%x", &value);

    printf("1");
    return 0;
}

#include<stdio.h>
int main()
{
int a,b,i;
scanf("%d",&a);
for(i=2;;i++){
    if(a%i==0){
    b=a/i;
    printf("%d%d\n",i,b);
    break;
    }
}
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main(){
  printf("0");
  return 0;
}

#include<stdio.h>
int main()
{
	char a[8];
	for (int i = 0; i < 8; ++i)
	{
		scanf("%c",&a[i]);
	}
	if (a[7]%2==0)
	{
		printf("0\n");
	}
	else
		printf("1\n");
}


A sequence of integers $$$b_1, b_2, \ldots, b_m$$$ is called good if $$$max(b_1, b_2, \ldots, b_m) \cdot min(b_1, b_2, \ldots, b_m) \ge b_1 + b_2 + \ldots + b_m$$$.A sequence of integers $$$a_1, a_2, \ldots, a_n$$$ is called perfect if every non-empty subsequence of $$$a$$$ is good.YouKn0wWho has two integers $$$n$$$ and $$$M$$$, $$$M$$$ is prime. Help him find the number, modulo $$$M$$$, of perfect sequences $$$a_1, a_2, \ldots, a_n$$$ such that $$$1 \le a_i \le n + 1$$$ for each integer $$$i$$$ from $$$1$$$ to $$$n$$$.A sequence $$$d$$$ is a subsequence of a sequence $$$c$$$ if $$$d$$$ can be obtained from $$$c$$$ by deletion of several (possibly, zero or all) elements.

The first and only line of the input contains two space-separated integers $$$n$$$ and $$$M$$$ ($$$1 \le n \le 200$$$; $$$10^8 \le M \le 10^9$$$). It is guaranteed that $$$M$$$ is prime.

Print a single integer  — the number of perfect sequences modulo $$$M$$$.

NoteIn the first test case, the perfect sequences are $$$[2, 2]$$$, $$$[2, 3]$$$, $$$[3, 2]$$$ and $$$[3, 3]$$$.In the second test case, some of the perfect sequences are $$$[3, 4, 3, 5]$$$, $$$[4, 5, 4, 4]$$$, $$$[4, 5, 5, 5]$$$ etc. One example of a sequence which is not perfect is $$$[2, 3, 3, 4]$$$, because, for example, the subsequence $$$[2, 3, 4]$$$ is not an good as $$$2 \cdot 4 < 2 + 3 + 4$$$.

#include <stdio.h>
#include <string.h>

#define N	202

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

int vv[N + 1], ff[N + 1], gg[N + 1];

void init(int md) {
	int i;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - md % i] * (md / i + 1) % md;
		ff[i] = (long long) ff[i - 1] * i % md;
		gg[i] = (long long) gg[i - 1] * vv[i] % md;
	}
}

int main() {
	static int dp[N + 1][N + 1];
	int n, md, a, b, k, l, s, ans;

	scanf("%d%d", &n, &md), init(md);
	ans = 0;
	for (a = 1; a <= n + 1; a++) {
		for (k = 0; k <= n; k++)
			memset(dp[k], 0, (a + 1) * sizeof *dp[k]);
		dp[0][0] = 1;
		for (b = a; b <= n + 1; b++) {
			for (k = n; k >= 0; k--)
				for (s = 0; s + (n - k) * (b - a) <= a && s + k * a <= a * (b - 1); s++) {
					int x = dp[k][s], k_, s_, lower, upper;

					if (x == 0)
						continue;
					/* l >= 1
					 * k + l <= n
					 * s + l * (b - a) + (n - (k + l)) * (b + 1 - a) <= a
					 * s + l * (b - a) + (k + l) * a <= a * b
					 *
					 * l >= 1
					 * l <= n - k
					 * l >= s + (n - k) * (b + 1 - a) - a
					 * l <= (a * b - s - k * a) / b
					 */
					lower = max(1, s + (n - k) * (b + 1 - a) - a);
					upper = min(n - k, (a * b - s - k * a) / b);
					for (l = lower; l <= upper; l++) {
						k_ = k + l, s_ = s + l * (b - a);
						dp[k_][s_] = (dp[k_][s_] + (long long) dp[k][s] * gg[l]) % md;
					}
				}
			if (b == a)
				dp[0][0] = 0;
		}
		for (s = 0; s <= a; s++)
			ans = (ans + (long long) dp[n][s] * ff[n]) % md;
	}
	printf("%d\n", ans);
	return 0;
}

#include <stdio.h>
#include <string.h>

#define N	200

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

int vv[N + 1], ff[N + 1], gg[N + 1];

void init(int md) {
	int i;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - md % i] * (md / i + 1) % md;
		ff[i] = (long long) ff[i - 1] * i % md;
		gg[i] = (long long) gg[i - 1] * vv[i] % md;
	}
}

int main() {
	static int dp[N + 1][N + 1];
	int n, md, a, b, k, l, s, ans;

	scanf("%d%d", &n, &md), init(md);
	ans = 0;
	for (a = 1; a	<= n + 1; a++) {
		for (k = 0; k <= n; k++)
			memset(dp[k], 0, (a + 1) * sizeof *dp[k]);
		dp[0][0] = 1;
		for (b = a; b <= n + 1; b++) {
			for (k = n; k >= 0; k--)
				for (s = 0; s + (n - k) * (b - a) <= a && s + k * a <= a * (b - 1); s++) {
					int x = dp[k][s], k_, s_, lower, upper;

					if (x == 0)
						continue;
					/* l >= 1
					 * k + l <= n
					 * s + l * (b - a) + (n - (k + l)) * (b + 1 - a) <= a
					 * s + l * (b - a) + (k + l) * a <= a * b
					 *
					 * l >= 1
					 * l <= n - k
					 * l >= s + (n - k) * (b + 1 - a) - a
					 * l <= (a * b - s - k * a) / b
					 */
					lower = max(1, s + (n - k) * (b + 1 - a) - a);
					upper = min(n - k, (a * b - s - k * a) / b);
					for (l = lower; l <= upper; l++) {
						k_ = k + l, s_ = s + l * (b - a);
						dp[k_][s_] = (dp[k_][s_] + (long long) dp[k][s] * gg[l]) % md;
					}
				}
			if (b == a)
				dp[0][0] = 0;
		}
		for (s = 0; s <= a; s++)
			ans = (ans + (long long) dp[n][s] * ff[n]) % md;
	}
	printf("%d\n", ans);
	return 0;
}