#include<stdio.h>
#include<string.h>
int main()
{
	long long int x,y,m,cnt=0;
	scanf("%lld",&x);
	scanf("%lld",&y);
	scanf("%lld",&m);

	if(x>=m || y>=m)
	{
		printf("%d\n",0);
		return 0;
	}
	if(x<=0 && y<=0)
	{
		printf("%d\n",-1);
		return 0;
	}
	if(x>y)
	{
		long long int tmp = x;
		x=y;
		y=tmp;
	}
	if(x<0)
	{
		cnt += -x/y;
		x+=y * cnt
	}
	while(x<m && y<m)
	{
		if(x<y)
			x+=y;
		else
			y+=x;
	}
	printf("%d\n",cnt);
	return 0;
}


#include <stdio.h>
#define lli long long int
lli n,i,j,u,k,l,x,y,d,s,t;
lli gg(lli x){int u=0;  while(x){u++;x/=10;} return u;}
lli ggg(lli n)
{
    while(n/10)n/=10;
    return n;
}
lli g(lli u)
{
    lli a=1;
    while(--u)a=10*a+1;
    return a;
}
lli f(lli n);
lli fff(lli n)
{
    lli u=gg(n);
    if(u==1) return 2+(11-n);
    if(ggg(n)<6) return 10000;
    return u+1+f(g(u+1)-n);
}
lli ff(lli n)
{
    lli u=gg(n);
    if(u==1)return n;
    return ggg(n)*u+(f(n-ggg(n)*g(u)));
}
lli f(lli n)
{
    if(!n)return 0;
    if(n<0)n*=-1;
    lli x,y,u=gg(n);
    x=ff(n);
    y=fff(n);
    return (x>y ? y : x);
}
int main()
{
    scanf("%lld",&n);
    x=n;
    while(x){u++;x/=10;}
    printf("%lld",f(n));
    return 0;
}


#include<stdio.h>
#include<algorithm>
int main()
{
    int a[3],n;
    scanf("%d",&n);
    scanf("%d",&a[0]);
    scanf("%d",&a[1]);
    scanf("%d",&a[2]);
    std::sort(a,a+3);
    int sum=0;
    n--;
    while(n!=0)
    {
        if(n%2==0) sum+=a[1];
        else if(n%2==1) sum+=a[0];
        n--;
    }
    printf("%d",sum);

    return 0;
}


 #include<stdio.h>
 main()
 {
     long long int n,k,i,j,l=1;
    scanf("%lld%lld",&n,&k);
    if(n%2==0)
    j=n/2+1;
    else if(n%2!=0)
    j=n/2+1+1;
    for(i=1;i<=n;i++)
      {
        if(i%2==0)
        {
        if(j==k)
        {
        printf("%ld",i);
        break;
        }
        j++;
        }
            else
            {
             if(l==k)
             {
             printf("%ld",i);
             break;
             }
             l++;
            }
      }
 return 0;
 }


#include <stdio.h>
#define mod 1000000007
long long findMod(long long a)
{
	return a>=0? (a%mod) : (mod-((-1*a)%mod));
}
int main()
{
	long long x,y,n,ans[7];
	scanf("%lld%lld",&x,&y);
	long long a,b,c,d;
	ans[1] = findMod(x);
	ans[2] = findMod(y);
	ans[3] = (findMod(y)-findMod(x)+mod)%mod;
	ans[4] = findMod(-x);
	ans[5] = findMod(-y);
	ans[6] = (findMod(x)-findMod(y)+mod)%mod;
	scanf("%lld",&n);
	if(n%6==0)
		printf("%lld\n",ans[6]);
	else
		printf("%lld\n",ans[n%mod]);
	return 0;
}


#include <stdio.h>
int main(int argc, char const *argv[])
{
	int a;
	scanf("%d",&a);
	for (int i = 2; i < d; ++i)
	{
		if(a%i == 0){
			printf("%d",i );

		}
	}
	return 0;
}


// C program to print largest contiguous array sum
#include<stdio.h>
typedef long long int ll;
ll max(ll a,ll b){
    return (a>b?a:b);
}
ll min(ll a,ll b){
    return (a<b?a:b);
}
int main()
{
    ll a,b,c,d,low2,high2,ans=0;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    for(ll i=d;i>=c;i--)
    {
        for(int j=b;j<=c;j++)
        {
            low2=max(a,i-j+1);
            high2=min(low2,b+1);
            ans+=(b-high2+1);
        }
    }
    printf("%lld",ans);
}


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

long long int XY(int A, int B, int C, int X_plus_Y)
{
	long long int x = 0;
	int i;
	int j;
	for(i=A;i<=B;i++)
	{
		j = X_plus_Y - i;
		if( (B<=j) && (j<=C) )
		{
			x++;
		}
	}

	return x;
}

long long int Z(int C, int D, int X_plus_Y)
{
	int min;
	long long int z;
	if( X_plus_Y-1 <= D)
	{
		min = X_plus_Y-1;
	}
	else
	{
		min = D;
	}

	z = min - C + 1;
	if(z<0)
	{
		return 0;
	}

	return z;
}

int main()
{
	// variable in description
	int T;
	int A, B, C, D;
	// variable to support
	long long int ans;
	long long int XY_num;
	long long int Z_num;
	// variable to judge
	int i;
	int j;
	int k;

		scanf("%d %d %d %d",&A,&B,&C,&D);

		ans = 0;

		for(j=A+B;j<=B+C;j++)
		{
			XY_num = XY(A,B,C,j);
			Z_num = Z(C,D,j);
			ans += XY_num*Z_num;
			//printf("%d %d\n",XY_num,Z_num);
		}

		printf("%lld\n",ans);

	return 0;
}


#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main ()
{
    int i=0,n,j;
    char s[100];
    scanf("%s",s);
    n=strlen(s);
    while (i<n)
    {
        if (isupper(s[i]) && islower(s[i+1]))
        {
            printf("%s",s);
            break ;
        }
        else
        {
            s[0]=toupper(s[0]);
            for (j=1;j<n;i++)
            {
                s[j]=tolower(s[j]);
            }
             printf("%s",s);

        }
        i++;
    }

    return 0;
}


#include<stdio.h>
#include<string.h>
int check(char[],char[]);
int main(){
   char s[100];
   scanf("%s",s);
   int a,b,c,d,t=0,flag=1;
   t=check(s,"Danil");
   a=check(s,"Olya");
   b=check(s,"Ann");
   c=check(s,"Slava");
   d=check(s,"Nikita");
   t=t+a+b+c+d;
   if(t==1)printf("YES");
   else printf("NO");
   return 0;
}
int check(char s[],char m[]){
   int flag=1,i,j,t=0;
   for(i=0;i<=strlen(s)-strlen(m);i++){
      flag=1;
      j=0;
      for(;j<=strlen(m)-1;j++){
         if(m[j]!=s[j+i]){
            flag=0;
            break;
         }
      }
      if(flag==1){
         t=t+1;
      }
   }
   return t;
}


#include<stdio.h>
#include<string.h>
int check(char[],char[]);
int main(){
   char s[100];
   scanf("%s",s);
   int a,b,c,d,t=0,flag=1;
   if(strcmp(s,"Danil")==0||strcmp(s,"Olya")==0||strcmp(s,"Ann")==0||strcmp(s,"Slava")==0||strcmp(s,"Nikita")==0)t=1;
   else if(strcmp(s,"Vanya")==0&&strcmp(s,"A")==0)){t=0;}
   else{
      t=check(s,"Danil");
      a=check(s,"Olya");
      b=check(s,"Ann");
      c=check(s,"Slava");
      d=check(s,"Nikita");
      t=t+a+b+c+d;
   }
   if(t==1)printf("YES");
   else printf("NO");
   return 0;
}
int check(char s[],char m[]){
   int flag=1,i,j,t=0;
   for(i=0;i<=strlen(s)-strlen(m);i++){
      flag=1;
      j=0;
      for(;j<=strlen(m)-1;j++){
         if(m[j]!=s[j+i]){
            flag=0;
            break;
         }
      }
      if(flag==1){
         t=t+1;
      }
   }
   return t;
}


#include<stdio.h>
#include<string.h>
int check(char[],char[]);
int main(){
   char s[100];
   scanf("%s",s);
   int a,b,c,d,t=0,flag=1;
   if(strcmp(s,"Danil")==0||strcmp(s,"Olya")==0||strcmp(s,"Ann")==0||strcmp(s,"Slava")==0||strcmp(s,"Nikita")==0)t=1;
   else if(strcmp(s,"Vanya")==0){t=0;}
   else{
      t=check(s,"Danil");
      a=check(s,"Olya");
      b=check(s,"Ann");
      c=check(s,"Slava");
      d=check(s,"Nikita");
      t=t+a+b+c+d;
   }
   if(t==1)printf("YES");
   else printf("NO");
   return 0;
}
int check(char s[],char m[]){
   int flag=1,i,j,t=0;
   for(i=0;i<=strlen(s)-strlen(m);i++){
      flag=1;
      j=0;
      for(;j<=strlen(m)-1;j++){
         if(m[j]!=s[j+i]){
            flag=0;
            break;
         }
      }
      if(flag==1){
         t=t+1;
      }
   }
   return t;
}


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

long long power(int m, int pow){
    if (pow == 1)
        return m;
    else{
        long long val = power(m, pow/2);
        val = (val * val) %1000000007;

        if (pow%2)
            val = (val * (long long)m) % 1000000007;
        return val;
    }

}

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

    if (k == 1)
        printf("%d\n", power(m,n));
    else{

        if (n>k){

             if (k%2)
                printf("%d\n", (m*m)%1000000007);
            else
                printf("%d\n", m);
        }

        else{
            int pow = k/2 + k%2;

            printf("%I64d\n", power(m,pow));
        }
    }

    return 0;
}


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

int M,ans;
int n,m,k,t;
long long lans;

main(){
    M=1e9+7;
    scanf("%d%d%d",&n,&m,&k);
    if(n<k){
        puts("0");
        return 0;
    }
    if(k%2==0){
        if(k==n){
            lans=1;
            t=k>>1;
            while(t--){
                lans*=m;
                lans%=M;
            }
            printf("%lld\n",lans);
            return 0;
        }
        printf("%d\n",m);
        return 0;
    }
    if(k==1){
        lans=1;
        t=n;
        while(t--){
            lans*=m;
            lans%=M;
        }
        printf("%lld\n",lans);
        return 0;
    }
    printf("%d\n",m*~-m);
    return 0;
}


#include <stdio.h>
long long n,dep,d[70];
void devide(long long k){
	while (k){
		dep++;
		d[dep]=k%2;
		k/=2;
	}
}
long long get(long long i){
	long long m=(1<<(dep))-1,c=0,k=i;
	while (k)
	{
		m>>=1;
		c++;
		if (k==m+1)
			break;
		if (k>m+1)
			k-=m+1;
	}
//	printf("%lld",d[c]);
	return c;
}
int main(void){
	long long x,y,i,sum=0;
	scanf("%lld%lld%lld",&n,&x,&y);
	devide(n);
	for (i=x;i<=y;i++)
		sum+=d[get(i)];
	printf("%lld\n",sum);
	return 0;
}


#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
string s , sl;
long long n , l , r , ans;
long long dfs(long long num) {
    if(num == 1) {
        return 1;
    }
    return 1 + 2 * dfs(num / 2);
}
void binsearch(long long le , long long ri , long long num) {
    long long mid = (le + ri) >> 1;
    if(ri < l || le > r || le > ri)
        return ;
    if(mid < l) {
        binsearch(mid + 1 , ri , num / 2);
    }
    else if(mid > r) {
        binsearch(le , mid - 1 , num / 2);
    }
    else {
        ans += num % 2;
        binsearch(le , mid - 1 , num / 2);
        binsearch(mid + 1 , ri , num / 2);
    }
}
int main() {
    cin >> n >> l >> r;
    if(n == 0) {
        cout << 0 << endl;
        return 0;
    }
    long long count = dfs(n);
    binsearch(1 , count , n);
    cout << ans << endl;
    return 0;
}


#include<stdio.h>
int i=0;
int b[100];
long long n,l,r,x;

long long le=1;
int sum=0;
long long k;

int sol(long long m)
{long long L=0,mid,R=le;int j;
if(m%2==0)return (1);
else

for(j=0;m!=(L+R)/2;j++)
{
	mid=(L+R)/2;
	if(m>mid)L=mid+1;
	if(m<mid)R=mid-1;
	}

return (b[j]);

}

int main()
{
scanf("%d%d%d",&n,&l,&r);

for(x=n;x>1;x/=2){

b[i++]=x%2;
le=2*le+1;
}

le=le-1;

for(k=l-1;k<=r-1;k++)
{sum+=sol(k);
}
printf("%d",sum);

return 0;
}


#include<stdio.h>
#define MAXN 100010
long long a[MAXN],b[MAXN];
int sign,flag;
int main(){
	void crash(long long a[],long long b[]);
	long long n;
	int r,l;
	int i,count；
	for(i=0;i<MAXN;i++){
		a[i]=-1;
		b[i]=-1;
	}
	scanf("%lld %d %d",&n,&r,&l);
	a[0]=n/2
	a[1]=n%2;
	a[2]=n/2;
	crash(a,b);
	count=0;
	if(sign>0){
		for(i=r-1;i<=l-1;i++){
			if(a[i]==1){
				count++;
			}
		}
    }
	else{
		for(i=r-1;i<=l-1;i++){
			if(b[i]==1){
				count++;
			}
		}
	}
	printf("%d",count);
	return 0;
}

void crash(long long a[],long long b[]){
	sign=1,flag=0;
	int i,quo,mod,count;
	for(i=0,count=0;a[i]!=-1;i++){
		if(a[i]!=1&&a[i]!=0){
			quo=a[i]/2;
			mod=a[i]%2;
			b[count]=quo;
			b[count+1]=mod;
			b[count+2]=quo;
			count=count+3;
			flag=1;
		}
		else{
			b[count]=a[i];
			count++;
		}
	}
	sign=sign*(-1);
	if(flag==1){
		crash(b,a);
	}
}


#include <cstdio>

typedef long long ll;

ll solve(ll n, ll l, ll r, ll x, ll y) {
    if (r < x || l > y || n == 0) return 0;
    if (n == 1) return 1;
    ll mid = (x + y) / 2;
    return solve(n / 2, l, r, x, mid - 1) + solve(n % 2, l, r, mid, mid) + solve(n / 2, l, r, mid + 1, y);
}

int main() {
    ll n, l, r;
    ll ans;
    scanf("%lld %lld %lld", &n, &l, &r);
    ll max = 1; while (max <= n) { max *= 2; }
    ans = solve(n, l, r, 1, max);
    printf("%lld\n", ans);
    return 0;
}


#include<stdio.h>
main()
{
    long int l,r,x,y,i,j,flag=0,s;
    double k,p;
    scanf("%ld%ld%ld%ld%lf",&l,&r,&x,&y,&k);
    for(i=l;i<=r;i++)
    {
        for(j=x;j<=y;j++)
        {   p=(double)j*k;
            if((double)i==p)
            {
                printf("YES\n");flag=1;
                goto s;
            }
        }
    } s:;
    if(flag==0)
    {
        printf("NO\n");
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
    int i,j;
    int l,r,x,y;
    double k;
    scanf("%d %d %d %d %lf",&l,&r,&x,&y,&k);
    for(i=l;i<=r;i++)
        {
            if(i/k<=y&&i/k>=x&&i%k==0)
            {
                printf("YES");
                exit(0);
            }
        }
    printf("NO");
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
int main()
{
	long int l,r,x,y,k,a,b,i,j,temp,check;
	scanf("%ld %ld %ld %ld %ld",&l, &r, &x, &y, &k);
	for(i=l;i<=r;i++)
	{
		check = 0;
		for(j = x;j<=y && j<=i;j++)
		{
			if(i%j == 0)
			{
				if(k == i/j)
				{
					printf("YES");
					check = 1;
					break;
				}
			}
		}
		if(check == 1)
		{
			break;
		}
	}
	if(check == 0)
	{
		printf("NO");
	}
}


#include <stdio.h>

// ftp = 7 http = 5

int controlar(char *c1, char *c2,int op)
{
    int i=0;

    if(c1[0]=='r' && c2[0]=='u' && op!=1)
    {
        i=1;
    }else
    {
     i=0;

    }
    return i;
}
int main()
{
   char dir_err[51]={0};
   int n,r,op;
   n=r=op=0;
   scanf("%s",dir_err);

       if (dir_err[n]=='h')
       {

            printf("http://");
            n=4;
            if (dir_err[n]=='r' && dir_err[n+1]=='u'){op++;}
       }else if (dir_err[n]=='f')
       {

           if (dir_err[3]=='h' && dir_err[4]=='t' && dir_err[5]=='t' && dir_err[6]=='p')
           {
            printf("ftp://http");
            n=7;
           }else
           {
            printf("ftp://");
            n=3;
            if (dir_err[n]=='r' && dir_err[n+1]=='u'){op++;}
           }
       }
    while(0==controlar(&dir_err[n],&dir_err[n+1],op) ){

               printf("%c",dir_err[n]);
               n++;
               op+2;

    }

       printf(".ru");
       n=n+2;
       if(dir_err[n]!='\0')
       {
            printf("/");
            do{
               printf("%c",dir_err[n]);
               n++;
           }while(dir_err[n]!='\0');

       }

}


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


#include<stdio.h>
int main(){
	long long int n,count,a,c,k,st,i,p,d;
	scanf("%lld",&n);
	count=0;

        d=0;
	for(i=2;i<=1000000;i++){
		st=n;
		k=st;
		c=0;
		a=0;

		if(i<n){
		while(k>1){
			k=st/i;
			if(k*i==st){
				c=0;
				a++;}
			else{
				c++;
				break;}
			st=st/i;
		}
		if(c==0){
			printf("%lld\n",i);
		       break;}
		if(c!=0 && a!=0){
			printf("1\n");
			break;}
		}
		else{
			d++;
			break;}
	}
		if(d>0)
			printf("%lld\n",n);

	return 0;
}


/* http://codeforces.com/problemset/problem/1243/C */
/* If n = r*s where gcd(r,s) = 1, return 1.
If n = p^k, return p. */

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

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


#include <stdio.h>

#define MD	1000000007

int power(int a, int b) {
	int p;

	if (b == 0)
		return 1;
	p = power(a, b / 2);
	p = (long long) p * p % MD;
	if (b % 2 == 1)
		p = (long long) p * a % MD;
	return p;
}

int solve(int x) {
	return power(2, x - 1);
}

int sign(int x) {
	int a, cnt;

	cnt = 0;
	for (a = 2; a * a <= x; a++) {
		if (x % a == 0) {
			x /= a;
			cnt++;
		}
		if (x % a == 0)
			return 0;
	}
	if (x > 1)
		cnt++;
	return cnt % 2 == 0 ? 1 : -1;
}

int main() {
	int x, y, a, sum;

	scanf("%d%d", &x, &y);
	if (y % x != 0) {
		printf("0\n");
		return 0;
	}
	y /= x;
	sum = 0;
	for (a = 1; a * a <= y; a++)
		if (y % a == 0) {
			sum = (sum + (sign(a) * solve(y / a) % MD) + MD) % MD;
			if (y / a != a)
				sum = (sum + (sign(y / a) * solve(a) % MD) + MD) % MD;
		}
	printf("%d\n", sum);
	return 0;
}


#include <stdio.h>

#define MAX(a, b) ((a > b) ? a : b)

int main(){
  int k, a, b;
  scanf("%d%d%d", &k, &a, &b);
  if(a >= k || b >= k || !a%k || !b%k){
    printf("%d\n", a/k+b/k);
    return;
  }
  printf("-1\n");
}


#include <stdio.h>

int all_same_horizon(char str[8]){
    int i, counter=0;
    for(i=0; str[i]!='\0'; i++){
        if(str[i]=='B') counter+=1;
    }
    if(counter==8) return 1;
    else return 0;
}

int B_counter(char str[8]){
    int i, count=0;
    for(i=0; str[i]!='\0'; i++){
        if(str[i]=='B') count++;
    }
    return count;
}

int main(void)
{
    int i,k=1, j,stroke=0, temp=0, final_stroke;
    char word[8];
    for(i=1; i<=8; i++){
        scanf("%s", word);
        if(all_same_horizon(word)==1) stroke++;
        else temp=temp+B_counter(word);
    }
    final_stroke=stroke+(temp/(8-stroke));
    printf("%d", final_stroke);
    return 0;
}


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

int main()
{
    int m,d;
    scanf("%d %d",m,d);
    if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)
    {
        if(d>=5)
        printf("6");
        else
        printf("5");
    }
    else
    {
        if(m==2)
        {
            if(d==1)
            printf("4");
            else
            printf("5");
        }
        else
        {
            if(d>=6)
            printf("6");
            else
            printf("5");
        }
    }

}


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

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
long long c[500][500], k = 0;

long long Arr(int m, int n){
	long long res = 1;
	while(m--){
		res *= n--;
		res %= 998244353;
	}
	return res;
}

void advance(int a){
	int i, j;
	for(i = k; i <= a; i++){//	printf("\n");
		for(j = 0; j <= i; j++){
			if(j == 0 || j == i){
				c[i][j] = 1;
			}
			else{
				c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
				c[i][j] %= 998244353;
			}
			//printf("%d ",c[i][j]);
		}
	}
}

long long count(int a, int b){
	int i;
	long long s = 0;
	if(a > b){
		a = a + b;
		b = a - b;
		a = a - b;
	}
	advance(a);
	for(i = 0; i <= a; i++){
	//	printf("%d ",s);
		s += c[a][i] * Arr(i, b);
		s %= 998244353;
	}
	return s;
}

int main(int argc, char *argv[]) {
	int a, b, c;
	long long s;
	scanf("%d %d %d", &a, &b, &c);
	s = count(a, b) * count(b, c);
	s %= 998244353;
	s *= count(a, c);
	s %= 998244353;
	printf("%d\n",s);
	return 0;
}


#include <stdio.h>

#define MOD % 998244353

long long C[2501][2501];

void Set_Combination(int a, int b)
{
	if (a == b || b == 0)
	{
		C[a][b] = 1;
		return;
	}
	if (!C[a - 1][b])
		Set_Combination(a - 1, b);
	if (!C[a - 1][b - 1])
		Set_Combination(a - 1, b - 1);
	C[a][b] = (C[a - 1][b - 1] + C[a - 1][b]) MOD;
}

long long Permutation(int a, int b)
{
	int k;
	long long r = 1;
	if (b == 0)
		return 1;
	for (k = a; k >= a - b + 1; k = k - 1)
	{
		r = (r * k)MOD;
	}
	return r;
}

void Island(int a, int b, int * ans)
{
	int i, j, small = (a >= b ? b : a);
	long long temp = 0;
	for (i = 0; i <= small;i = i + 1)
	{
		temp = temp + C[b][i] * Permutation(a, i)MOD;
	}
	*ans = (*ans * temp MOD);
	return;
}

int main(void)
{
	int a, b, c, ans = 1;

	for (a = 0; a <= 2500; a = a + 1)
	{
		for (b = 0; b <= a; b = b + 1)
		{
			Set_Combination(a, b);
		}
	}
	scanf("%d %d %d", &a, &b, &c);
	Island(a, b, &ans);
	Island(b, c, &ans);
	Island(c, a, &ans);
	printf("%d", ans);
	return 0;
}


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

int main()
{
	int a, b, c, t;
	scanf("%d %d %d", &a, &b, &c);
	t = (int) ceil(a * c / b) - c;
	printf("%d\n", t);
	return 0;
}


#include<stdio.h>
int main()
{
short a,b,c,temp;
scanf("%hd%hd%hd",&a,&b,&c);
if(a<=b)
printf("0");
else
{
temp=(a-b)*c;
c=temp/b;
if(temp%b>0)
c++;
printf("%hd",c);
}
return 0;
}


#include <stdio.h>

int main ()
{
    long long int l, n, buttons;

    scanf ("%l64d", &n);

    l = 1, buttons = 0;

    while (l <= n)
    {
        buttons += l * (n - l) + 1;

        ++l;
    }

    printf ("%l64d\n", buttons);

    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<time.h>
#include<stdlib.h>
int cmp[250];
int cnt[10];
int cmp1[250];
int calc(int a){
	int cntx=0;
	while(a){
		a/=7;
		cntx++;
	}
	return cntx;
}
int insert(int x,int fix[]){
	if(x==0){
		fix[0]=0;
		return 1;
	}
	int i,k; i=k=0;
	while(x){
		fix[i++]=x%7;
		x/=7;
	}
	for(k=0;k<i/2;k++){
		int temp = fix[k];
		fix[k] = fix[i-k-1];
		fix[i-k-1]=temp;
	}

	return i;
}
int fill(int x,int fix[],int t){
	int i,k; i=k=0; int lock[250];
	for(i=0;i<x;i++){
		lock[i]=fix[i];
	}
	for(i=0;i<t-x;i++){
		fix[i]=0;
	}
	for(i=t-x;i<x+(t-x);i++){
		fix[i] = lock[k++];
	}
}
int same(int x,int y){
	int i;
	memset(cnt,0,sizeof(cnt));
	for(i=0;i<x;i++){
		cnt[cmp[i]]++;
	}
	for(i=0;i<y;i++){
		cnt[cmp1[i]]++;
	}
	for(i=0;i<7;i++){
		if(cnt[i]>1)
		return 0;
	}
	return 1;
}
int main(){
	int a,b,c,d,e,f,g,h;
	scanf("%d%d",&a,&b);
	int t = calc(a-1); int t1=calc(b-1);
	if(t+t1>7){
		printf("0");
		return 0;
	}
	int i; int cnt=0;
	for(i=0;i<a;i++){
		int val = insert(i,cmp);
		if(val<t){
			fill(val,cmp,t);
			val=val+(t-val);
		}
		for(c=0;c<b;c++){
			int val1 = insert(c,cmp1);
			if(val1<t1){
				fill(val1,cmp1,t1);
				val1=val1+(val-t1);
			}
			if(same(val,val1))
			cnt++;
		}
	}
	printf("%d",cnt);
}


#include <stdio.h>

int check(int a, int b, int c)
{
	int oc[7]={0}, sum=0,flag=0,i=0;

	while(a)
	{
		oc[a%7]++;
		a/=7;
		sum++;
	}

	while(b)
	{
		oc[b%7]++;
		b/=7;
		sum++;
	}

	while(i<7)
	{
		if(oc[i]>1) flag=1;
		i++;
	}

	if(c-sum>1) flag=1;

	if(c-sum>0 && oc[0]==1) flag=1;

	if(flag==1) return 0;

	else return 1;
}

int main(void) {
	int n,m,i=0,a,d=0,ans=0;

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

	a=n-1;
	while(1)
	{
		d++;
		a/=7;
		if(a==0) break;
	}

	a=m-1;
	while(1)
	{
		d++;
		a/=7;
		if(a==0) break;
	}

	if(i>7) printf("0");

	else
	{
		i=0;
		while(i<n)
		{
			int j=0;

			while(j<m)
			{
				ans+=check(i,j,d);
				j++;
			}

			i++;
		}

		printf("%d",ans);
	}

	return 0;
}


#include <stdio.h>
#include <stdbool.h>
typedef long long i64;
i64 gcd(i64 a, i64 b) {
	return b == 0 ? a : gcd(b, a % b);
}
bool is_prime(i64 n) {
	if(n <= 1) return false;
	else if(n <= 3) return true;
	else if(n % 2 == 0 || n % 3 == 0) return false;
	for(i64 i = 5; i * i <= n; i += 6) if(n % i == 0 || n % (i + 2) == 0) return false;
	return true;
}
i64 f(i64 x, i64 y) {
	i64 ans = 0, d;
	while(y != 0) {
		if(is_prime(x)) {
			ans += x < y ? y / x + y % x : y;
			break;
		}
		while((d = gcd(x, y)) == 1LL && y != 0) ans++, y--;
		if(y == 0) break;
		x /= d, y /= d;
	}
	return ans;
}
int main(void) {
	i64 x, y;
	scanf("%lld%lld", &x, &y);
	printf("%lld\n", f(x, y));
	return 0;
}


include <stdio.h>
int main()
{
  int n,i,j,state=1;
  scanf("%d",&n);
  int circle[n];
  int flea=1;
  for(i=0;i<n;i++)
    circle[i]=0;
  circle[0]=1;
  for(i=1;i<=n;i++)
    {
      flea=flea+i;
      if(flea%n==0)
	flea=n;
      else
	flea=(flea%n);
      circle[flea-1]=1;
    }

  for(j=0;j<n;j++)
    {
      if(circle[j]!=1)
	{
	  state=0;
	  break;
	}
    }

  if(state==1)
    puts("YES");
  else if(state==0)
    puts("NO");
  return 0;
}


#include<stdio.h>
int main()
{
	int a;
	scanf("%d",a);
	(a & a-1)?printf("NO"):printf("YES");
	return 0;

}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main ()
{
	int *v, n, i, j, t;
	scanf ("%d",&n);
	v = (int*)calloc(n, sizeof(int));

	v[0] = 1;
	i = 2;
	j=0;
	while (i <= n*n) {
		t = i - 1;
		while (t>0) {
			j+=1;
			t--;
			if (j==n)
				j=0;
		}
		j++;
		if (j==n)
			j=0;
		if (j<n)
			v[j] = 1;
		i++;
	}

	t=0;
	for (i=0; i<n; i++) {
		if (v[i] == 0) t++;
	}

	if (t==0)
		printf ("YES\n");
	else
		printf ("NO\n");

	free (v);

	return 0;

}


#include<stdio.h>
  int main(){
	  int i,j,n;

	  scanf("%d"&n);

	  n&(n - 1) ? printf("N0") : printf("YES");

	  return 0;
  }


#include <stdio.h>

int main()  {
    int n;
    scanf("%d", &n);
    printf("%s", n&(n-1) ? : "YES" ? "NO");
    return 0;
}


#include<stdio.h>
int main()
{
long  int x,y,z,sum=0;
scanf("%ld %ld %ld",&x,&y,&z);

if(x==y)
printf("%ld",(z*2)+b+a);

else if(x>y)
printf("%ld",(z*2)+(x*2)+1);

else if(x<y)
printf("%ld",(z*2)+(y*2)+1);

return(0);
}


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


#include<stdio.h>
#include<stdlib.h>
int power(int a,int b)
{
    int sum=1;
    int i;
    for(i=0; i<b; i++)
        sum*=a;
    return sum;
}
int main()
{
    char s[1000];
    long long int n=0,i,sum=0;
    scanf("%s",s);
    for(i=0; i<strlen(s); i++)
    {
        n+=(s[i]-'0')*power(2,strlen(s)-i-1);
    }
    while(n!=1)
    {
        n/=4;
        if(n==4)
            ;
        else
            sum++;
    }
    printf("%lld",sum+1);
    return 0;
}


#include<stdio.h>
int main()
{
    int sum=2,b=1,n,i;
    scanf("%d",&n);

    if(n==1){
        b=1;
    }
    else{
    for(i=1; ;i++){
        sum=sum*2;
        if(sum>n){
            b++;
            sum=sum/2;
            n=n-sum;
            if(n==1){
                break;
            }
            sum=2;
        }
        if(sum==n){
            break;
        }
    }
}
    printf("%d",b);
return 0;
}


#include <stdio.h>

int main(int argc, char *argv[])
{
  int n = *argv[1] - 48 , i,five = 5;
  for(i = 0; i< n; i++)
    {
      five *=5;
    }

  printf("%d",five%100);

}


#include<stdio.h>
using namespace std;
int main(){
    int m,n,k;
    int x,y;
    scanf("%d%d%d",&n,&m,&k);
    x=((k-1)/2)/m+1;
    y=k-m*(x-1)*2;
    y=(y-1)/2+1;
    printf("%d %d ",x,y);
    if(k%2==0)
        printf("R\n");
    else
        printf("L\n");
    return 0;
}


#include<stdio.h>
#include<math.h>
int dgt(long long int n)
{
        int i,j,k;
        i=0;
        while(n>0)
        {
                n=n/10;
                i++;
        }
        return i;
}

long long int power(long long int x,long long int y)
{
    long long int temp,ty,my;
    //long long int mod;
    //mod=1000000007;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    ty=(temp)*(temp);
    if (y%2 == 0)
        {

                return ty;
        }
    else
        {
                my=(x)*(ty);
                return my;
        }
}

int main()
{
        long long int w,m,k,x,y,s=0,l=0,ans;
        int d;
        scanf("%lld",&w);
        scanf("%lld",&m);
        scanf("%lld",&k);
        d=dgt(m);
        while(s<w)
        {
                if(s==0)
                {
                        s=s+k*d*(power(10,d)-m);
                        l=l+power(10,d)-m;
                        d++;
                }
                else
                {
                        s=s+k*d*(power(10,d)-power(10,d-1));
                        l=l+power(10,d)-power(10,d-1);
                        d++;
                }
        }
        //printf("%lld\n",s);
        if(s==w)
        {
                ans=l;
        }
        else if(s>w)
        {
                x=(s-w)/((d-1)*k);
                //printf("%lld\n",s-w);
                //printf("%lld\n",x);
                //printf("%d\n",d);
                y=power(10,d-1);
                //printf("%lld\n",y);
                if((s-w)==((d-1)*k*x))
                        ans=l-x;
                else
                        ans=l-x-1;
        }
        printf("%lld\n",ans);
        return 0;
}


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

int main()
{
    int n,i,arr[6],count=0;
    scanf("%d",&n);
    if(n==0)
    printf("0");
    else if(n<10)
    printf("1");
    else
    {
        int n1=n;
        while(n1)
        {
            count++;
            int arr[6]={0};
            for(i=0;i<6;i++)
                {
                    if(n)
                    {arr[i]=n%10;
                    n/=10;}
                }
            int max=0;
            for(i=0;i<6;i++)
            if(max<arr[i])
                max=arr[i];
        n1-=max;
        n=n1;
        }
        printf("%d",count);
    }
    //printf("Hello world!\n");
    return 0;
}


#include<stdio.h>
int maxDigit(unsigned long long);

int main(){
    unsigned long long x, turns = 0;
    scanf("%l64d", &x);
    while(x > 0){
            x -= maxDigit(x);
            turns++;
    }
    printf("%l64d", turns);
    return 0;
}

int maxDigit(unsigned long long x){
    int maxD = 0, i;
    char str[19];
    sprintf(str, "%l64d", x);
    for(i = 0; str[i] != '\0'; i++){
          if(str[i] == '9')
                  return 9;
          else if((int) (str[i] - '0') > maxD)
                  maxD = str[i] - '0';
    }
    return  maxD;
}


#include<stdio.h>
int main()
{
    int i,j,t,b,min;
    scanf("%d",&t);
    int a[t];
    for(i=0;i<t;i++)
    {
        scanf("%d",&a[i]);
    }
    int max[t-1];
    for(i=1;i<t-1;i++)
    {
        int max1=0;
        for(j=1;j<t;j++)
        {
            if(j!=i)
            {
                b=a[j]-a[j-1];
                if(b>max1)
                {
                    max[i]=b;
                    max1=b;
                }
            }
            else if(j==i)
            {
                b=a[j+1]-a[j-1];
                if(b>max1)
                {
                    max[i]=b;
                    max1=b;
                }
                j++;
            }
        }
    }
    int l;
    min=max[1];
    for(l=2;l<=t-2;l++)
    {
        if(min>max[l])
        {
            min=max[l];
        }
    }
    printf("%d\n",min);
    return main();
}


#include <stdio.h>

#define M	1000000007

int factorial(int n) {
	return n == 0 ? 1 : (long long) factorial(n - 1) * n % M;
}

int main() {
	int i, n, f, g;

	scanf("%d", &n);
	f = factorial(n);
	if (n % 2 == 0)
		printf("0\n");
	else {
		g = 1;
		for (i = 1; i <= n; i += 2)
			g = (long long) g * i % M;
		f = f * g % M;
		printf("%d\n", f);
	}
	return 0;
}


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

#define MODULO 1000000007

int ma[20][20];
int b[20], col[20];
int n;

long long sols[17] = {0,1,0,18,0,1800,0,670320,0,734832000,0,890786230,0,695720788,0,150347555,0};

long long dfs(int x, int k);
long long precalc();

int main(){

   	//precalc();

	int n;
	scanf("%d", &n);
	printf("%I64\n", sols[n]);

#ifdef _AT_HOME_
    system("pause");
#endif

    return 0;
}

long long dfs(int x, int k){
	if (k>n){
		return 1;
	}
	int i;
	int t = 0;
	for (i=1;i<=n;i++){
		if (b[ma[k][i]] || col[i]) continue;
		b[ma[k][i]] = 1;
		col[i] = 1;
		t +=dfs(i, k+1);
		b[ma[k][i]] = 0;
		col[i] = 0;
	}
	return t;
}

long long precalc(){
	int tt;
	for (tt=1;tt<16;tt+=2){

		int i,j;
	    n = tt;

	    for (i=1;i<=n;i++){
	    	for (j=1;j<=n;j++){
	    		ma[i][j] = (i-1+j-1) % n + 1;
	    	}
	    }

	    long long sol = 0;
	    for (i=1;i<=1;i++){
	    	b[ma[1][i]] = 1;
	    	col[i] = 1;
	    	sol += dfs(i, 2);
	    	if (sol>MODULO){
	    		sol -= MODULO;
	    	}
	    	b[ma[1][i]] = 0;
	    	col[i] = 0;
	    }

	    sol *= n;
	    sol %= MODULO;

	    long long fak = 1;
	    for (i=2;i<=n;i++){
	    	fak *= i;
	    	fak %= MODULO;
	    }

	    sol *= fak;
	    sol %= MODULO;

	    printf("%I64d\n", sol);
	}
}


#include<stdio.h>
int main()
{
    int n,h,m,i,j,num,ans=0;
    scanf("%d%d%d",&n,&h,&m);
    int l[n],r[n],x[n];
    for(i=0; i<m; i++)
        scanf("%d %d %d",&l[i],&r[i],&x[i]);
    for(i=1; i<=n; i++)
    {
        num=h;
        for(j=0; j<m; j++)
        {
            if(i>=l[j] && i<=r[j])
            {
                if(num>x[j])
                    num=x[j];
            }
        }
        ans=ans+(num*num);
    }
    printf("%d\n",ans);
    return 0;
}


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

int main(){
int n, c, price[101], i, selisih[100], ans=0, a=0, ans2, b=0;
scanf("%d %d",&n, &c);

for(i=0;i<n;i++){
    scanf("%d",&price[i]);

}
for(i=0;i<n-1;i++){
    if(price[i]>price[i+1]){
        selisih[b]=price[i]-price[i+1];

        b++;
        a++;

    }
}
for(i=0;i<a;i++){
    if(selisih[i]>ans){
        ans=selisih[i];
    }
}

ans2=ans-c;
if(ans2>=0){
printf("%d",ans2);
}
else{
    return 1;
}
return 0;
}


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

#define MAX_LEN 1e2

int main(int argc,char** argv) {
    int n,t;
    char* s = (char*)malloc(n);
    scanf("%d%d",&n,&t);
    scanf("%s",s);
    while(t--) {
        for(int i = 0;i < n-1;) {
            if(s[i] == 'G') {
                i++;
                continue;
            }
            if(s[i+1] == 'G') {
                s[i] = 'G';
                s[i+1] = 'B';
                i+=2;
            }
        }
    }
    printf("%s",s);
    free(s);
}


#include <stdio.h>

int main(){
    int a, b, i, res1 = 0, res2 = 0; res3 = 0;
    scanf("%d %d", &a, &b);
    for (i = 1; i <= 6; i++)
        if (abs(a-i) > abs(b-i)) res1++;
        else if (abs(a-i) == abs(b-i)) res2++;
        else if (abs(a-i) < abs(b-i)) res3++;
        printf("%d %d %d", res1, res2, res3);
    return 0;
}


#include<iostream>
#include<string.h>
#define max(a,b) a>b?a:b;
#define min(a,b) (a>b?b:a)
int main()
{
   int T;
   while(scanf("%d",&T)!=EOF)
   {
   	while(T--)
   	{
   		int n,sum,k,w[110],v[110],dp[110][35],a[35],b[35];
   		memset(dp,0,sizeof(dp));
   		memset(a,0,sizeof(a));
   		memset(b,0,sizeof(b));
   		scanf("%d %d %d",&n,&sum,&k);
   		for(int i=0;i<n;i++)
   			scanf("%d",&v[i]);
   		for(int i=0;i<n;i++)
   			scanf("%d",&w[i]);
   		for(int i=0;i<n;i++)
   		{
   			for(int j=sum;j>=w[i];j--)
   			{
   				for(int z=1;z<=k;z++)
				{
					a[z]=dp[j][z];
					b[z]=dp[j-w[i]][z]+v[i];
				}
				for(int x=1,y=1,z=1;z<=k&&(x<=k||y<=k);)
				{
					if(a[x]>b[y])
					{
		            	dp[j][k]=a[x];
		                x++;
		            }
		            else
					{
		                dp[j][k]=b[y];
		                y++;
		            }
		            if(dp[j][k] != dp[j][k-1])
		            	k++;
				}
			}
		}
		printf("%d\n",dp[sum][k]);
	}
   }
    return 0;
}


#include<stdio.h>
#include<math.h>
int n,a,b,t,i;
int lgx(int x,int y)
{
    int i;
    while(y)
    {i=x%y;
    x=y;
    y=i;}
    return x;
}
int main()
{
    scanf("%d%d%d",&a,&b,&n);
    t=a*b/lgx(a,b);
    if(n%t)
    printf("%d\n",(n/t+1)*t);
    else
    printf("%d\n",n/t*t);
    return 0;
    }
//QAQ


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

int determine(int *guesses, int *bulls, int *cows, int n);
bool is_solution(int k, int *guesses, int *bulls, int *cows, int n);
bool fits(int k, int guess, int bulls, int cows);

int main() {
	int n = 0, k = 0, result = 0;
	int *guesses = NULL;
	int *bulls = NULL;
	int *cows = NULL;

	scanf("%d", &n);

	guesses = calloc(n, sizeof(int));
	bulls = calloc(n, sizeof(int));
	cows = calloc(n, sizeof(int));

	for(k=0; k<n; k++) {
		scanf("%d %d %d", &guesses[k], &bulls[k], &cows[k]);
	}

	result = determine(guesses, bulls, cows, n);

	switch(result) {
		case 0:
			printf("Incorrect data");
			break;
		case 1:
			printf("Need more data");
			break;
		default:
			printf("%d", result);
			break;
	}

	printf("\n");

	free(guesses);
	free(bulls);
	free(cows);

	return 0;
}

int determine(int *guesses, int *bulls, int *cows, int n) {
	int k = 0, j = 0, result = 0;

	k = 1000;

	while(k<=9999 && j<=1) {
		if(is_solution(k, guesses, bulls, cows, n)) {
			result = k;
			j++;
		}
		k++;
	}

	if(j==2)
		result = 1;

	return result;
}

bool is_solution(int k, int *guesses, int *bulls, int *cows, int n) {
	bool cont = true;
	int j = 0;

	while(cont && j<n) {
		cont = fits(k, guesses[j], bulls[j], cows[j]);
		j++;
	}

	return cont;
}

bool fits(int k, int guess, int bulls, int cows) {
	int Guess[4];
	int K[4];
	bool selected[4];
	int j = 0, i = 0, weight = 1, weightx = 10, countb = 0, countc = 0;

	for(j=0; j<4; j++) {
		Guess[j] = (guess%weightx) / weight;
		K[j] = (k%weightx) / weight;
		weight = weightx;
		weightx *= 10;
	}

	for(j=0; j<4; j++) {
		if(Guess[j]==K[j])
			countb++;
	}

	if(bulls != countb)
		return false;

	for(j=0; j<4; j++)
		selected[j] = false;

	for(i=0; i<4; i++)
		for(j=0; j<4; j++) {
			if(i!=j && !selected[i] && Guess[i]==K[j]) {
				countc++;
				selected[i] = true;
			}
		}

	if(cows != countc)
		return false;

	return true;
}


#include <stdio.h>

int main() {
	long int x,y;
	scanf("%ld %ld",&x,&y);
	if(x==y)
	    printf("=");
	else if((x==2)&&(y==3))
	    printf("<");
	else if((x==3)&&(y==2))
	    printf(">");
	else if((x==2)&&(y==4))
	    printf("=");
	else if((x==4)&&(y==2))
	    printf("=");
	else if(x==1)
	    printf("<");
	else if(y==1)
	    printf(">")
	else if(x<y)
	    printf(">");
	else
	    printf("<");
	return 0;
}


#include <stdio.h>
#define MAX 1000000001
int main()
{
  int *angka,input,i,penanda=0,temp;
  angka = (int *)malloc(sizeof(int));
  angka[0] = 1;
  angka[1] = 2;
  angka[2] = 3;
  angka[3] = 4;
  angka[4] = 5;
  scanf("%d",&input);
  for(i=5;i<input;i+=2)
  {
     angka[i] = angka[penanda];
     angka[i+1] = angka[penanda];
     penanda++;
  }
  temp = angka[input-1];
  if(temp==1)
  {
    printf("Sheldon");
  }
  else if(temp==2)
  {
    printf("Leonard");
  }
  else if(temp==3)
  {
    printf("Penny");
  }
  else if(temp==4)
  {
    printf("Rajesh");
  }
  else if(temp==5)
  {
    printf("Howard");
  }
  return 0;
}


#include <stdio.h>
int main()
{
    long long int w, h;
    scanf("%lld %lld", &w, &h);
    printf("%lld", ((w*w)/4 * (h*h)/4));
    return 0;
}


#include <stdio.h>
#define MIN(i,j) i<j?i:j
int main()
{
	int i,j,w,h,a,b,min;
	double count=0;
	scanf("%d %d",&w,&h);
	min = MIN(w,h);
	for(a=2;a<=w;a+=2){
		for(b=2;b<=w;b+=2)
		{
			count+=(w-a+1)*(h-b+1);
		}
	}
	printf("%.0lf\n",count);

}


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

#define UL 0
#define UR 1
#define BL 2
#define BR 3
#define h 1
//printf("here! line: %d ", __LINE__); fflush(stdout)
typedef unsigned long long	ult;

typedef struct	s_po
{
	int x, y;
}				t_po;

typedef struct	s_sq
{
	int surface, width, height;
	t_po corner[4];
}				t_sq;

t_sq	make_square(int x1, int y1, int x2, int y2);
int		c_inshape(t_po p, t_sq s);

void	check_periphery(t_sq s1, t_sq s2, t_sq s3)
{
	t_sq s = make_square(s2.corner[UL].x - 1, s2.corner[UL].y - 1, s2.corner[BR].x + 1, s2.corner[BR].y + 1);
	t_po c1, c2;
	t_po inc[4];
	inc[UL].x = 1;
	inc[UL].y = 0;
	inc[UR].x = 0;
	inc[UR].y = 1;
	inc[BR].x = -1;
	inc[BR].y = 0;
	inc[BL].x = 0;
	inc[BL].y = -1;
	int i = -1;
	h;
	//printf("\n");
	while (++i < 4)
	{
		c1 = s2.corner[i];
		c2 = s2.corner[i == UL ? UR : (i == UR ? BR : (i == BR ? BL : UL))];
		while (c1.x != c2.x || c1.y != c2.y)
		{
			if (c_inshape(c1, s1) && !c_inshape(c1, s3))
			{
				printf("YES\n");
				exit(1);
			}
			c1.x += inc[i].x;
			c1.y += inc[i].y;
			//printf("\rc1.x = %d c2.x = %d c1.y = %d c2.y = %d", c1.x, c2.x, c1.y, c2.y);
		}
	}
	h;
}

int		c_inshape(t_po p, t_sq s)
{
	if (p.x >= s.corner[UL].x && p.x <= s.corner[BR].x &&
		p.y >= s.corner[UL].y && p.y <= s.corner[BR].y)
		return (1);
	return (0);
}

t_sq	make_square(int x1, int y1, int x2, int y2)
{
	t_sq ret;

	ret.corner[UL].x = x1;
	ret.corner[UL].y = y1;
	ret.corner[UR].x = x2;
	ret.corner[UR].y = y1;
	ret.corner[BR].x = x2;
	ret.corner[BR].y = y2;
	ret.corner[BL].x = x1;
	ret.corner[BL].y = y2;
	ret.height = y2 - y1;
	ret.width = x2 - x1;
	ret.surface = ret.height * ret.width;
	return (ret);
}

int		main()
{
	int x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	scanf(" %d %d %d %d", &x3, &y3, &x4, &y4);
	scanf(" %d %d %d %d", &x5, &y5, &x6, &y6);
	t_sq s1, s2, s3;
	t_po p;
	s1 = make_square(x1, y1, x2, y2);
	s2 = make_square(x3, y3, x4, y4);
	s3 = make_square(x5, y5, x6, y6);
	h;
	if (s3.surface + s2.surface < s1.surface)
	{
		printf("YES\n");
		return 0;
	}
	else
	{
		h;
		if ((c_inshape(s1.corner[UL], s2) || c_inshape(s1.corner[UL], s3)) &&
			(c_inshape(s1.corner[UR], s2) || c_inshape(s1.corner[UR], s3)) &&
			(c_inshape(s1.corner[BL], s2) || c_inshape(s1.corner[BL], s3)) &&
			(c_inshape(s1.corner[BR], s2) || c_inshape(s1.corner[BR], s3)))
		{
			check_periphery(s1, s2, s3);
		}
		else
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
}


#include<stdio.h>
struct mystuct{
	int x1,y1,x2,y2;
};
int main(void)
{
	mystuct input1,input2,input3;
	scanf("%d %d %d %d",&input1.x1,&input1.y1,&input1.x2,&input1.y2);
	scanf("%d %d %d %d",&input2.x1,&input2.y1,&input2.x2,&input2.y2);
	scanf("%d %d %d %d",&input3.x1,&input3.y1,&input3.x2,&input3.y2);
	getchar();
	if(input2.x1 <= input1.x1 && input2.y1 <= input1.y1 &&
	   input2.x2 >= input1.x2 && input2.y2 >= input1.y2) printf("NO"); //b全覆盖a
	else if(input3.x1 <= input1.x1 && input3.y1 <= input1.y1 &&
	   	 	input3.x2 >= input1.x2 && input3.y2 >= input1.y2) printf("NO"); //c全覆盖a
	else if(input2.y1 <= input1.y1 && input2.y2 >= input1.y2 &&
			input3.y1 <= input1.y1 && input3.y2 >= input1.y2 &&
			input2.x1 <= input1.x1 && input3.x1 <= input2.x2 &&
			input3.x2 >= input1.x2) printf("NO"); //b,c左右覆盖
	else if(input3.y1 <= input1.y1 && input3.y2 >= input1.y2 &&
			input2.y1 <= input1.y1 && input2.y2 >= input1.y2 &&
			input3.x1 <= input1.x1 && input2.x1 <= input3.x2 &&
			input2.x2 >= input1.x2) printf("NO"); //c,b左右覆盖
	else if(input2.x1 <= input1.x1 && input2.x2 >= input1.x2 &&
			input3.x1 <= input1.x1 && input3.x2 >= input1.x2 &&
			input2.y1 >= input1.y2 && input3.y1 >= input2.y1 &&
			input3.y2 >= input1.y2 && input2.y2 >= input1.y2) printf("NO"); //b,c上下覆盖
	else if(input3.x1 <= input1.x1 && input3.x2 >= input1.x2 &&
			input2.x1 <= input1.x1 && input2.x2 >= input1.x2 &&
			input3.y1 >= input1.y2 && input2.y1 >= input3.y1 &&
			input2.y2 >= input1.y2 && input3.y2 >= input1.y2) printf("NO"); //c,b上下覆盖
	else printf("YES"); //还有白色部分露出
	return 0;
}


#include <stdio.h>
int main()
{
    int a,b,c,d,sum=0,i;int temp[10]={0};
    scanf("%d %d %d %d",&a,&b,&c,&d);
    temp[0]=a;
    temp[1]=c;
    temp[2]=d;
    int min=100;
    for(i=0;i<3;i++)
    {
        if(temp[i]<min)
        min=temp[i];
    }
    for(i=0;i<min;i++)
    {
        sum=sum+256;
        a--;c--;d--;
    }
   while((a||b)!=0)
    {
       sum=sum+32;
    a--;b--;
    }
 printf("%d\n",sum);
    return 0;
}


#include<stdio.h>
long long int main(long long int argc, char const *argv[])
{
	long long int n,m;
	scanf("%lld%lld",&n,&m);
	long long int a[m];
	for(long long i=0;i<m;i++)a[i]=0;
	long long int b=2;
	for(long long i=1;i<=n;i++){
		a[b%m]++;
		b=b+(2*i+1);
	}
	b=0;
	long long int sum=0;
	for(long long i=1;i<=n;i++){
		sum+=a[(m-b%m)%m];
		b=b+(2*i+1);
	}
	printf("%lld\n",sum);
	return 0;
}


#include <bits/stdc++.h>
#include <stdint.h>
#include <stdio.h>

uint64_t getBlkCount(uint32_t l,uint32_t b,uint32_t div)
{
    uint64_t blkCnt = 0;
    for(int i=1;i<=l;i++)
    for(int j=1;j<=b;j++)
    {
        blkCnt+= (((i*i + j*j)%div)==0);
    }
    return blkCnt;
}

uint64_t getCount(uint32_t n,uint32_t m)
{
    int q = n/m, r = n%m;

    uint64_t fullBlkCnt = getBlkCount(m,m,m);
    uint64_t halfBlkCnt = getBlkCount(r,m,m);
    uint64_t remBlkCnt  = getBlkCount(r,r,m);

    uint64_t blkCnt = fullBlkCnt*q*q + halfBlkCnt*2*q + remBlkCnt;

    return (blkCnt);
}

int main()
{
    uint32_t n,m;
    uint64_t count;
    scanf("%d %d",&n,&m);
    printf("%lu\n",getCount(n,m));
}


#include<stdio.h>
int main()
{int t=0,i=1,g=1;
char s[100];
scanf("%s",&s);
while(s[i]!='\0')
{g++;
if(s[i]!=s[i-1])
g=1;
if(g>=7)
t=1;
}
if(t==1)
printf("Yes");
else
printf("No");
return 0;
}


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

#define MAX 200010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

bool visited[76][76][76][76][2], dp[76][76][76][76][2];

bool F(int x1, int y1, int x2, int y2, int p){
    if (x1 == 0 && y1 == 0) return true;
    if (x2 == 0 && y2 == 0) return false;
    if (visited[x1][y1][x2][y2][p]) return dp[x1][y1][x2][y2][p];

    bool res = false;
    if (p){
        if (x1 && (x1 - 1) != x2 && F(x1 - 1, y1, x2, y2, p ^ 1)) res = true;
        if (y1 && (y1 - 1) != y2 && F(x1, y1 - 1, x2, y2, p ^ 1)) res = true;
    }
    else{
        res = true;
        if (x2 && (x2 - 1) != x1 && F(x1, y1, x2 - 1, y2, p ^ 1)) res = false;
        if (y2 && (y2 - 1) != y1 && F(x1, y1, x2, y2 - 1, p ^ 1)) res = false;
        if (x2 && y2 && (x2 - 1) != x1 && (y2 - 1) != y1 && F(x1, y1, x2 - 1, y2 - 1, p ^ 1)) res = false;
    }

    visited[x1][y1][x2][y2][p] = true;
    return (dp[x1][y1][x2][y2][p] = res);
}

int main(){
    int i, j, k, l, x1, y1, x2, y2, polycarp = 0, vasilly = 0;

    while (scanf("%d %d %d %d", &x1, &y1, &x2, &y2) != EOF){
        if (F(x1, y1, x2, y2, 1)) puts("Polycarp");
        else puts("Vasiliy");
    }
    return 0;
}


#include <stdio.h>
int max(int a,int b);
int main()
{  int a,b,c,d,i,j,k,x1,y1,x2,y2;
   scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
   if(x1>x2 && y1>y2)
   {   printf("Vasiliy");

   }
   else if(x2==0 || y2==0)
   {
       if(x1+y1<=x2+y2)
       {
           printf("Polycarp");
       }
       else
       {
           printf("Vasiliy");
       }
   }

   else if(x2>x1 && y2>y1)
   {   if(x1+y1<=max(x2,y2))
       {
           printf("Polycarp");
       }
       else if(x1+1==x2 && y1+1==y2 )
       {printf("Polycarp");}
       else
       {
           printf("Vasiliy");
       }
   }
   else if(x1==x2)
   {
       if(y1<y2)
       {
           printf("Polycarp");
       }
       else if(x1+y1<=max(x2,y2))
       {
           printf("Polycarp");
       }
       else
       {
           printf("Vasiliy");
       }

   }
   else if(y1==y2)
   {
       if(x1<x2)
       {
           printf("Polycarp");
       }
       else if(x1+y1<=max(x2,y2))
       {
           printf("Polycarp");
       }
       else
       {
           printf("Vasiliy");
       }

   }
   else
   {
       if(x1+y1<=max(x2,y2))
       {
           printf("Polycarp");
       }
       else
       {
           printf("Vasiliy");
       }
   }
   return 0;

 }
 int max(int a,int b)
 {
     if(a>=b)
     {
         return a;
     }
     else
     {
         return b;
     }

 }


#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int a[n],b[n],x=0,y=0;
    for(int i=0;i<n;i++)
    {scanf("%d",a[i]);
    x=x+a[i];
    }
     for(int i=0;i<n;i++)
   { scanf("%d",b[i]);
       y=y+b[i];
   }
    if(x>=y)
    printf("Yes");
    else
    printf("No");
    return 0;
}


#include<stdio.h>
int main() {
	int n;
	while (scanf("%d", n) != EOF) {
		if (n > 1 && n <= 10)
			printf("0\n");
		else if(n == 11)
			printf("4\n");
		else if (n == 12)
			printf("4\n");
		else if (n == 13)
			printf("4\n");
		else if (n == 14)
			printf("4\n");
		else if (n == 15)
			printf("4\n");
		else if (n == 16)
			printf("4\n");
		else if (n == 17)
			printf("4\n");
		else if (n == 18)
			printf("4\n");
		else if (n == 19)
			printf("4\n");
		else if (n == 20)
			printf("15\n");
		else if (n == 21)
			printf("0\n");
		else if (n == 22)
			printf("0\n");
		else if (n == 23)
			printf("0\n");
		else if (n == 24)
			printf("0\n");

	}
	return 0;
}


#include<stdio.h>

int main()
{
    int n,i,count=0,j,k;
    scanf("%d",&n);
    char str[n];
    int ara[n];
    scanf("%s",str);
    for(i=0,j=0;i<n;i++){
        if(str[i]=='*'){
            count+=1;
            ara[j]=i;
            j++;
        }
    }
    //printf("%d",j);
    int ara_dif[21]={0};
    if(count<5){
        printf("no");
    }
    else{
        for(i=0;i<j-1;i++){
            for(k=i+1;k<j;k++){
               ara_dif[ara[k]-ara[i]]++;
            }
        }
        for(i=0;i<21;i++){
            if(ara_dif[i]>=4){
                printf("yes");
                break;
            }
        }
        if(i==21)printf("no");
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long int x,y,z,a,b,c,c1,c2,c3,i;
    scanf("%ld %ld %ld",&x,&y,&z);
    scanf("%ld %ld %ld",&a,&b,&c);
    if(x>a)
        return printf("NO\n");
    c2=a-x+b-y;
    if(c2<0)
        return printf("NO\n");
    c3=c2+c-z;
    if(c3<0)
        return printf("NO\n");
    else
        printf("YES\n");
    return 0;

}


//holiday of inequality
#include<stdio.h>
int main(void)
{
int n;
scanf("%d",&n);
int min=0;
int ctr=0;
int m=1;
for(int q=n;n>0;q--)
{
ctr+=q*m;
if(q!=n)
m++;

}

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


#include <stdio.h>
#include <stdlib.h>
int main()
{   int nb=1,mult=1;
    unsigned n,*a;
   scanf("%u",&n);
   a=(unsigned *)malloc(n*sizeof(unsigned));
   for(int i=0;i<n;i++)
    scanf("%u",&a[i]);
   int i=0;
   while(a[i]!=1)
    i++;
   for(;i<n;i++)
   {
   if(a[i]==1)
   {
       nb*=mult;
       mult=1;

   }
   else
    mult++;
    //printf("%d:%d-%d\t",a[i],mult,nb);
   }
  printf("\n%d",nb);

    return 0;
}


#include<stdio.h>
#include<iostream>

using namespace std;

int main(){
    long long int n,sum=0,x,y;
    scanf("%lld",&n);

    if(n==0)
       cout<<n<<endl;
    else{

    if(n%2==0){
       x=(n/2)-1;
       y=(n/2)+1;
    }
    else{
       x=n/2;
       y=(n/2)+1;
    }
    while(x>0){
       sum+=(x%10);
       x/=10;
    }
    while(y>0){
       sum+=(y%10);
       y/=10;
    }
    printf("%lld\n",sum);
  }
    return 0;
}


#include<stdio.h>

int main()
{
    char a[200];
    scanf("%s",a);
    int i,c=0,co=0;
    for(i=0;i<strlen(a);i++)
    {
    if(a[i]=='o')
    co++;
    else
    c++;
    }

    if(c==0)
    printf("YES");
    else
    {
    if(c%co==0)
    printf("YES");
    else
    printf("NO");
    }

    return 0;
}


#include <stdio.h>

main()
{
   int i=0, j=0;
   char a;
   while(a!='\n')
   {
       scanf("%c", &a);
       if(a=='o')
        i++;
       else if(a=='-')
        j++;
   }
   if((j>=i && j%i==0) || j==0)
   {
       printf("YES");
   }
   else
   {
       printf("NO");
   }
}


#include <stdio.h>
#include <string.h>
int equidistance(char *str) {
    int links=0,pearls=0;
    while (*str) {
        if ((*str)=='-') {
            links++;
        } else {
            pearls++;
        }
        str++;
    }
    return (links%pearls==0);
}
int main() {
    char neck[101];
    scanf("%s",neck);
    if (equidistance(neck)) {
        printf("YES");
    } else {
        printf("NO");
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
int main(){
  int i,k=0,b;
  char a[100],p[1]="o";
  scanf("%[^\n]%*c",a);
  b=strlen(a);
  for(i=0;i<b;i++)
     {
  	    if(p[0]==a[i])
  	       k++;
  	 }

  	 if((b-k)%k==0)
  	 printf("Yes");
  	 else if((b-k)%k!=0)
  	 printf("No");

}


#include<stdio.h>
#include<string.h>
int main(){
int n,i,j,k;
int link=0;
int pearl=0;
char s[1000];
scanf("%s",&s);
n=strlen(s);
for(i=0;i<n;i++){
if(s[i]=='-'){
link++;
}
if(s[i]=='o'){
pearl++;
}

}
if(link%pearl==0){
printf("YES");
}else{
printf("NO");
}

}


#include<stdio.h>
int main(void)
{
    int i,pearl=0,link=0;
    char string[105];
    scanf("%s",string);
    for(i=0;string[i]!='\0';i++)
    {
        if(string[i]=='o')
            pearl++;
        else
            link++;
    }
    if(!(link%pearl)||!pearl)
        printf("%s\n","YES");
    else
        printf("%s\n","NO");
    return 0;
}


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

int main()
{
    int n, m;

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

    int ans = 0;

    int temp;
    int cnt6, cnt3, slot;
    int top = 0;
    while (n > 0 || m > 0)
    {
        if (n != 0) {
            temp = 2 * n;

            n = 0;
            if (m > 0) {
                cnt3 = (temp-top)/3;
                cnt6 = (temp - top)/6;
                slot =
                //printf("cnt6 : %d\n", cnt6);
                if (m >= cnt3) {
                    //printf("t1\n");
                    n+=cnt6;
                    m-=cnt3;
                    top += cnt3*3;
                } else {
                    //printf("t2\n");
                    n += m;
                    m = 0;
                    top += m*3;
                }
            }
            ans+=temp;
        } else {
            //printf("%d %d %d\n", n, m, top);
            top+=m*3;
            m=0;

        }

    }
    if (top > ans) {
        printf("%d\n", top);
    } else
        printf("%d\n", ans);

    return 0;
}


#include <stdio.h>

int main(){
	long long n, m, hn, hm, tester = 6, r;

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

	hn = 6 * ((n - 1)/ 2) + 2 + 2 * ((n - 1) % 2);
	hm = 3 * (2 * m - 1);

	while (tester < hn || tester < hm){
		if (hn > hm){
			r = (hn / 2) % 3;

			if (r == 1)
				hn -= 4;
			else if (r == 2)
				hn -= 6;

			if (tester > hn)
				hn = tester;
		}
		else{
			hm -= 6;

			if (tester > hm)
				hm = tester;
		}

		tester += 6;
	}

	if (hn > hm)
		printf("%lld", hn);
	else
		printf("%lld", hm);

	return 0;
}


#include <stdio.h>
int count(int n,int m)
{
    int r;
    while(m)
    {
        r = n%m;
        n = m;
        m = r;
    }
    return n;
}

int main()
{
    int a,b,c,d,p,q,k;
    while(scanf("%d %d %d %d",&a,&b,&c,&d))
    {
        p = a*d;
        q = b*c;
        if(p>q)
            k=p;p=q;q=k;
        k = count(q,p);
        p = p/k;
        q = q/k;
        printf("%d/%d\n",q-p,q);
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long a,b;
    scanf("%lld%lld",&a,&b);
    long long count=1;
    while(a!=1 || b!=1)
    {
        if(b>a)
        {
            count++;
            b=b-a;
        }
        else
        {
            count++;
            a=a-b;
        }
    }
    printf("%lld\n",count);
    return 0;
}


#include<stdio.h>
int a[1000];
int isprime(int k)
{
    int j;
    for(j=2;j<=k/2;j++)
        {
            if(k%j==0)
            return 0;
        }
        return 1;
}

int main()
{
    int i,j,k,l=0,m,n,t=0;
    scanf("%d%d",&n,&k);
    if(k==0)
    {
        printf("YES");
        return 1;
    }
    for(i=2;i<=n;i++)
    {
                if(isprime(i)==1)
                {
                a[l]=i;

                l++;
                }
    }
    for(i=0;i<l-1;i++)
    {
        m=a[i]+a[i+1]+1;

        for(j=i+2;j<l;j++)
        {
            if(m==a[j])
            {
                t=t+1;
                if(t==k)
                {
                    printf("YES");
                break;
                }
            }
        }
        if(t==k)
        break;
    }
    if(t<k)
    printf("NO");
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
  int i,j,k,l,m,n;
  int x1, x2, a, b, fg, fgg;
  int mod;
  int stone;

  while(scanf("%d%d%d%d",&x1,&x2,&a,&b)==4){
    stone = x2 - x1;
    fg = 0;
    if(stone < 0) stone *= -1, k = a, a = b, b = k, a *= -1, b *= -1, fg = 1;
    if(b <= 0){ puts("DRAW"); continue; }

    fgg = 0;
    if(a <= 0) fgg = 1, a = 1;
    mod = stone % (a+b);
    if(mod == 0){
      if(fgg) puts("DRAW"); else puts("SECOND");
      continue;
    }
    if(mod < a){
      puts("DRAW");
      continue;
    }

    if(stone > b && fgg){
      puts("DRAW");
      continue;
    }

    stone -= mod;
    puts("FIRST");
    if(fg==0) printf("%d\n",x2-stone);
    else      printf("%d\n",x2+stone);
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	int a;
	cin>>a;
	int sd=log(a)/log(3);
	sd=pow(3,sd);
	int aw=a/sd;
	if(a%sd!=0)
	{
		aw++;
	}
	cout<<aw<<"\n";
}


#include<stdio.h>
int main()
{
    long long int n=0;

    scanf("%lld",&n);
    while(n!=0)
    {
        n=n/3
    }
    printf("%lld",(n/3)+1);

    return 0;
}


#include <stdio.h>
int main(){
	int n=0;
	scanf("%d",&n);
	int s=0,t=0,a[n],k=0,j=1;
	a[0]=getchar();
	for(int i=0;i<n;i++){a[i]=getchar()-48;}
	while((!k)){
		if(j==n)break;
		for(int i=0;i<j;i++)s+=a[i];
		int e=0;
		for(int i=j;i<n;i++){
			if(a[i]==0)continue;
			e=1;
			t=t+a[i];
			//printf("%d\n",t);
			if(t>s)break;
			if(t==s)t=0;

		}
		if(e&&(t==0))k=1;
		if(t!=s){
			s=0;t=0;j++;continue;
		}
	}
	if(k)printf("YES");else printf("NO");
}


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

int main(){
	int size, i;
	scanf("%d", &size);
	short *arr = malloc(sizeof *arr * size);
	char in;
	for(i = 0; i < size; ++i){
		scanf("%*[\n]");
		scanf("%c", &in);
		arr[i] = in - '0';
	}
	int j, isTrue = 0;
	for(i = 0; i < size; ++i){
		int key = 0;
		int counter = i;
		while(counter != -1)
			key += arr[counter--];
		j = i + 1;
		while(j < size){
			int sum = 0;
			int k = j;
			while(sum < key && k < size)
				sum += arr[k++];
			while(k < size && arr[k] == 0)
				k++;
			if(sum == key)
				j = k;
			else
				break;
		}
		if(j == size && i != size - 1){
			puts("YES");
			isTrue = 1;
			break;
		}

	}
	if(!isTrue)
		puts("NO");

}


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

    int k,l,m,n,d,count=0,i;
    while(scanf("%f%f%f%f%f",&k,&l,&m,&n,&d)!=EOF)
    {
        for(i=1; i<=d; i++)
        {
            if(i%k==0||i%l==0||i%m==0||i%n==0)
                count++;
        }
        printf("%d\n",count);
        count=0;
    }

}


#include <stdio.h>

#define rep(i,n) for(i=0;i<n;i++)
#define N 404

int x, y, n, d, vx[20], vy[20], mem[N][N];

int rec( int a, int b )
{
	if( a*a + b*b > d*d ) return 1;
	int & ans = mem[a+N/2][b+N/2];
	if( ans > -1 ) return ans;
	int i;
	rep(i,n) if( !rec( a+vx[i], b+vy[i] ) ) return ans = 1;
	return ans = 0;
}

int main()
{
	int i, j;
	rep(i,N) rep(j,N) mem[i][j] = -1;
	scanf( "%d%d%d%d", &x, &y, &n, &d );
	for( i = 0; i < n; i++ ) scanf( "%d%d", &vx[i], &vy[i] );
	printf( rec(x,y) ? "Anton\n" : "Dasha\n" );
	return 0;
}


#include<stdio.h>
#include<math.h>
int main () {
	int a[100],i,j,n,m,k;
	do {
		printf("n=");
		scanf("%d",&n);
		printf("m=");
		scanf("%d",&m);
		printf("k=");
		scanf("%d",&k);
	} while (n<1||m>n||m<1||k<1);
	for (i=0;i<n;i++) {
		//printf("nhap tien phong so %d =\n",i+1);
		scanf("%d",&a[i]);
	}
	int dem=0;
	int d[100];
	for (i=0;i<n;i++) d[i]=0;
	for(i=0;i<n;i++) {
		if (a[i]<=k&&a[i]!=0) {
			dem++;
			d[i]=abs(i+1-m);
		}
	}
	if (dem ==0) printf("ko co phong phu hop");
	else {
		int min=n-1,j;
		for(i=0;i<n;i++) {
			if (d[i]!=0&&d[i]<=min) {
				min=d[i];
				j=i;
			}
		}
	//printf("phong phu hop: %d\n khoang cach den crush : %d",j+1,min);
	printf("%d",min)

	}
}


#include <stdio.h>

int main()
{
    int p, l, i;

    char s;

    scanf("%c", &s);

    for(i = p = l = 0; s == '-' || s == 'o'; i++){

        if(s == '-') l++;
        else  p++;
        scanf("%c", &s);
    }

    if(l % p == 0)printf("YES\n");
    else printf("NO\n");

    return 0;
}


#include <stdlib.h>
int main()
{
    int i,a=0,b=0;
    char s[100];
    scanf("%s",s);
    int l=strlen(s);
    for(i=0;i<l;i++)
    {
        if(s[i]=='-')
            a++;
        if(s[i]=='o')
            b++;
    }
    if(a%b==0)
        printf("YES");
    else if(b==0)
        printf("YES");
    else
        printf("NO");
    return 0;
}


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

int main(void){
  char *neck = (char *) malloc(sizeof(char) * 101);
  scanf("%s", neck);
  int length = strlen(neck);
  int pearls = 0;
  int links = 0;
  for(int i = 0; i < length; i++){
    if(*(neck+i) == 'o'){
      pearls++;
    }
    else if(*(neck+i) == '-'){
      links++;
    }
  }
  if(links%pearls == 0){
      printf("YES\n");
  }
  else{
      printf("NO\n");
  }
}


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

int main(void) {
	char necklace[100];
	scanf("%s",necklace);
	int len = strlen(necklace);
	int pearls = 0, links = 0;
	for(int i = 0; i < len;i++){
	    if(necklace[i] == 'o')
	    pearls++;
	    else
	    links++;
	}
	int result = links % pearls;
	if(result == 0)
	printf("YES");
	else
	printf("NO");
	return 0;
}


#include<stdio.h>
int read_line(char str[] ) {
    int i=0;
    char c=getchar();
    while (c!=EOF && c!='\n')
    {
        str[i]=c;
        c=getchar();
        i++;
    }
    str[i]='\0';
    return i;
}
int main()
{
	char str[];
	int len=read_line(str);
	int link=0;
	int pearl=0;
	for (int i=0; i<len; i++)
	{
		if (str[i]=='-')
		{
			link++;
		}
		else if (str[i]=='o')
		{
			pearl++;
		}
	}
	if (link==0|| pearl==0)
	{
		printf ("YES");
	}
	else if (link%pearl==0)
	{
		printf ("YES");
	}
	else
	{
		printf ("NO");
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define N 100

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
	char input[N];
	int i,j;
	int a = 0,b = 0;
	i = 0;
	while((input[i] = getchar()) != '\n'){
		i++;
	}
	for(j = 0;j < i;j++)
	{
		if(input[j] == 'o')
		{
			a++;
		}
		else if(input[j] == '-');
		{
			b++;
		}
	}
	if(a==0 || b == 0 || b%a == 0)
	{
		printf("YES");
	}
	else
	{
		printf("")
	}
	return 0;
}


#include<stdio.h>
int main()
{
    int l =0;
    int p=0;
    char n;
    while(scanf("%c",&n) !=EOF){
        if(n == '-') l++;
        else if( n == 'o') p++;
    }
    if(l % p == 0)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include <stdio.h>
int main()
{
    char s[100];
    scanf("%s",s);
    int i,a=0,b=0;
    for(i=0;s[i]!='\0';++i)
    {
        if(s[i]=='-')
        a++;
        if(s[i]=='o')
        b++;

    }

    if(a%b==0&&b!=0)
    printf("YES");
    else if(b==0)

     printf("NO");
      else if(a==0)

     printf("YES");
     else
     printf("NO");

}


#include <stdio.h>
#include <string.h>
int main()
{
	int p = 0,l = 0,i,j;
	char A[10000];
	scanf("%s", A);
	int len = strlen(A);
	for (i = 0; i < len; i++){
		if (A[i] == '-'){
			l = l + 1;
		}
		else if (A[i] == 'o'){
			p = p + 1;
		}
	}
	if (l%p == 0){
		printf("YES\n");
	}
	else printf("No\n");
	return 0;
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<deque>
#include<stack>
#include<string>

long long int asd( long long int r);

int main()
{
    long long int n, b, p, m, r;
    scanf("%I64d %I64d %I64d", &n, &b, &p);
    r=n;
    long long int ans=0;
    while(r>1)
    {
        m=(r)/2; ans+=m; //r+=m-pow(2,m);
        r+=m-m*2;
    }
    b=ans*(b*2+1);
    p=p*n;
    printf("%I64d %I64d\n", b, p);
}

/*long long int asd( long long int r)
{
    long long int m=0; while(r>0)
    {
        r/=2;
        m++;
    }
    return m-1;
}*/


#include<stdio.h>
int main()
{
   long long int n;
    scanf("%lld",&n);
    long long int i=0,s[100000]={0};
    while(1)
    {
        n++;
        i++;
        while(n%10==0)
        {
            n=n/10;
        }
        s[n]=s[n]+1;
        if(s[n]>1)
        break;
    }
    printf("%lld",i);
    return 0;
}


#include<stdio.h>

int main()
{
     long long a=0,b=0;
     scanf("%lld %lld",&a,&b);
     long long a2=a,b2=b,r=a2%b2;
     while(r!=0)
     {
	  a2=b2;
	  b2=r;
	  r=a2%b2;
     }

     long long i=0,  t=a*b/b2;
char *p1="Dasha";

char *p2="Masha";
char *p3;

     if(a<b)
     {
	  a2=a;
	  b2=b;

     }
     else
     {
	  b2=a;
	  a2=b;

	  p3=p1;
	  p1=p2;
	  p2=p3;
     }

     int f1=0,f2=0;
     for(i=a2;i<t;i++)
     {
	  if(i%a2==0)
	  {
	       ++f1;
	       f2=0;
	       if(f1>1)break;
	  }
	  else if(i%b2==0)
	  {
	       ++f2;
	       f1=0;
	       if(f2>1)break;
	  }

     }

     if(i%a2==0 && i%b2==0)
	  printf("Equal");
     else if(f1==2)
	  printf(p1);
     else if(f2==2)printf(p2);
     return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
    int n, k;
    int y = 0;
    int g, t;
    int i;
    char s[101];
    scanf("%d%d", &n, &k);
    for(i = 0; i < n; i++)
    {
        scanf("%c", &s[i]);
        if(s[i] == 'G')
            g = i;
        if(s[i] == 'T')
            t = i;
    }
    if (g < t)
    {
        int q = g;
        g = t;
        t = q;
    }
    if (((g - t)%k) == 0)
    {
        for (i = t; i < g; i = i + k)
        {
            if(s[i] == "#")
            {
                printf("NO");
                y = 1;
                break;
            }
        }
        if (y == 0) printf("YES");
    }
    else printf("NO");
    return 0;
}


#include<stdio.h>
int main()
{
int r,g,b,countr,countb,countg,remainr,remainb,remaing,count=0;
scanf("%d%d%d",&r,&g,&b);
countr=r/3;
remainr=r%3;
countg=g/3;
remaing=g%3;
countb=b/3;
remainb=b%3;
while(remainr!=0||remainb!=0||remaing!=0)
{
remainr=remainr-1;
remaing=remaing-1;
remainb=remainb-1;
count++;
}
printf("%d",countr+countb+countg+count);
return 0;
}


#include <stdio.h>
long long int max,min,mid,ans,c[3],lol;
#define setmax() c[0]>c[1]?(max=0,c[2]>c[max]?max=2:1):(max=1,c[2]>c[max]?max=2:1)
#define setmin() c[0]<=c[1]?(min=0,c[2]<=c[min]?min=2:1):(min=1,c[2]<=c[min]?min=2:1)
#define setmid() ((max+min)==1)?(mid=2):(((max+min)==2)?(mid=1):(mid=0))
//#define setall() (setmax(),setmin(),setmid())
int main()
{
	scanf("%lld %lld %lld",&c[0],&c[1],&c[2]);
	setmax();
	setmin();
	setmid();
	while(1)
	{
		if((c[max]-2)>=0 && (c[mid]-1)>=0)
		{
			c[max]-=2;
			c[mid]-=1;
			ans++;
			setmax();
			setmin();
			setmid();
		}
		else if(c[0]==1 && c[1]==1 && c[2]==1)
		{
			ans++;
			break;
		}
		else break;
	}
	printf("%lld\n",ans);
	return 0;
}


#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

long long min(long long a, long long b){
	return (a<b)?a:b;
}

long long max(long long a, long long b){
	return (a>b)?a:b;
}

int main(){
    long long r,g,b;
    scanf("%lld %lld %lld",&r,&g,&b);
    long long sum = r+g+b;
    long long max_val = max(r,max(g,b));
    long long min_val = min(r,min(g,b));
    long long mid_val = sum-max_val-min_val;
    long long cnt = 0;
    while(max_val >1 && mid_val >0){
        max_val-=2;
        mid_val-=1;
        sum-=3;
        max_val = max(max_val,max(mid_val,min_val));
        min_val = min(max_val,min(mid_val,min_val));
        mid_val = sum-max_val-min_val;
        cnt++;
    }
    if(max_val >0 && mid_val >0 && min_val >0)
        cnt++;
    printf("%lld",cnt);
    return 0;
}


#include <stdio.h>

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int binsearch(int a, int x) {
	int low, high, mid;

	low = 1;
	high = a / x;

	while (low <= high) {
		mid = (low + high) / 2;
		if (mid * x < a)
			low = mid + 1;
		else if (mid * x > a)
			high = mid - 1;
		else
			return mid;
	}
	return -1;
}

int main() {
	int a, b, x, y, g;
	long long i, j, k, n, m;

	scanf("%d%d%d%d", &a, &b, &x, &y);
	g = gcd(x, y);
	x /= g, y /= g;
	i = binsearch(a, x);
	j = binsearch(b, y);
	k = a / x < b / y ? a / x : b / y;
	n = i * x, m = i * y;
	if (n * m < j * x * j * y) {
		n = j * x;
		m = j * y;
	}
	if (n * m < k * x * k * y) {
		n = k * x;
		m = k * y;
	}
	if (n < 0)
		n = -n;
	if (m < 0)
		m = -m;
	if (a < x || b < y)
		printf("0 0\n");
	else
		printf("%lld %lld\n", n, m);
	return 0;
}


#include <stdio.h>

int main()
{
    int a,b,x,y;
    int deltab=0;
    scanf("%d %d %d %d",&a,&b,&x,&y);

    while(1)
    {
        if((b-deltab)==0||x==0||y==0)
        {
            printf("0 0\n");
            return -1;
        }
        else if((x*(b-deltab))%y==0&&((x*(b-deltab))/y)<=a)
            break;
        else
            deltab++;
    }
    printf("%d %d\n",((x*(b-deltab))/y),(b-deltab));
    return 0;
}


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


#include<stdio.h>

int main()
{
	long long int n,i,k;
	scanf("lld %lld",&n,&k);
	for(i=0;i<k;i++) {
		if(n%2==0)
			n/=2;
		if(n%5==0)
			n/=5;
	}
	printf("%d",n);
	for(i=110;i<k;i++)
	{
		printf("0");
	}
	return 0;
}


#include <stdio.h>

int main()
{
	long long n, k;
	long long i;
	scanf("%lld %lld", &n, &k);
	for (i = 0; (n - i - i*k) > n / 2; i++);
	if (n - i - k*i < 0)
		i--;
	printf("%lld %lld %lld", i, k*i, n - i - k*i);
}


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

#define MOD 1000003

long long int mod(long long int p, long long int m)
{
	if(p==0)
		return 1;
	else if(p==1)
		return 2;
	else if(p%2)
		return (mod(1,m)*mod(p-1,m))%MOD;
	else
		return (mod(p/2,m)*mod(p/2,m))%MOD;
}

int main()
{
	char p[100],s[100];
	scanf("%s",p);

	for(long long int i=0;p[i]!='\0';i++)
	{
		if(p[i]=='>')
		{
			strcat(s,"1000");

		}
		else if(p[i]=='<')
		{
			strcat(s,"1001");
		}
		else if(p[i]=='+')
		{
			strcat(s,"1010");
		}
		else if(p[i]=='-')
		{
			strcat(s,"1011");
		}
		else if(p[i]=='.')
		{
			strcat(s,"1100")
		}
		else if(p[i]==',')
		{
			strcat(s,"1101");
		}
		else if(p[i]=='[')
		{
			strcat(s,"1110");
			//puts(s);
		}
		else
		{
			strcat(s,"1111");
			//puts(s);
		}
	}

	long long int ans=0,flag=0;
	for(long long int i=strlen(s)-1;i>=0;i--)
	{
		long long int temp=0;
		if(s[i]=='1')
			temp = mod(flag,MOD);
		ans = (ans+temp)%MOD;
		flag++;
	}
	printf("%lld\n", ans);
	return 0;
}


#include<stdio.h>
int max(int,int);
int max(int a,int b)
{
    if(a>b)
    return a;
    else
    return b;
}
int main()

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


#include<stdio.h>
long long f[23],n,s,sum;
long long power(long long a, long long b, long long MOD) {
long long x = 1, y = a;
    while(b > 0) {
        if(b%2 == 1) {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD;
        b /= 2;

    }
    return x;
}

long long modInverse(long long a,long long m) {
    return power(a,m-2,m);
}

long long binomialCoeff(long long n, long long k)
{
    long long i,res = 1;
    if (k >( n - k))
        k = n - k;
    for ( i = 0; i < k; ++i)
    {
        res =(res* (n - i))%1000000007;
        res =(res* modInverse((i + 1),1000000007))%1000000007;
    }

    return res;
}
void recursion(long long i,long long pow,int fac){
	if(pow>s)	return;
	if(i==n+1){
		sum=(sum+fac*binomialCoeff(n+s-pow-1,s-pow))%1000000007;
		return;
	}
	recursion(i+1,pow,fac);
	recursion(i+1,pow+f[i]+1,fac*-1);
}
int main(){
	long long i,j,k,l;
	scanf("%lld %lld",&n,&s);
	for(i=1;i<=n;i++)	scanf("%lld",&f[i]);
	recursion(1,0,1);
	sum=(sum+1000000007)%1000000007;
	printf("%lld\n",sum);
	return 0;
}


#include<stdio.h>
long long f[23],n,s,sum;
int c[23];
void function(){
	int i,t1;
	i=1;
	while(1){
		if(c[i]==0){
			c[i]=1;
			break;
		}else{
			c[i]=0;
			i++;
		}
	}
}

long long power(long long a, long long b, long long MOD) {
long long x = 1, y = a;
    while(b > 0) {
        if(b%2 == 1) {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD;
        b /= 2;

    }
    return x;
}

long long modInverse(long long a,long long m) {
    return power(a,m-2,m);
}

long long binomialCoeff(long long n, long long k)
{
    long long i,res = 1;
    if (k >( n - k))
        k = n - k;
    for ( i = 0; i < k; ++i)
    {
        res =(res* ((n - i)%1000000007))%1000000007;
        res =(res* modInverse((i + 1),1000000007))%1000000007;
    }

    return res;
}
void recursion(int i,long long pow,int fac){
	int j;
	i=0;
	while(1){
		fac=1;
		j=0;
		pow=0;
		for(i=1;i<=n;i++){
			pow=pow+c[i]*(f[i]+1);
			if(c[i]==1){	fac=fac*-1;j++;
			}
		}
		if(pow<=s){
			sum=(sum+fac*binomialCoeff(n+s-pow-1,s-pow))%1000000007;
		}
		if(j==n)	break;
		function();
	}
}

int main(){
	long long i,j,k,l;
	scanf("%lld %lld",&n,&s);
	for(i=1;i<=n;i++)	scanf("%lld",&f[i]);
	recursion(1,0,1);
	sum=(sum+1000000007)%1000000007;
	printf("%lld\n",sum);
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
typedef long long ll;

const int dy[] = {1,0,-1,0};
const int dx[] = {0,1,0,-1};

int d[100];
char s[105];
int vx[105], vy[105];
int ix, iy;
int main() {
  int a,b;
  while(scanf("%d%d", &a, &b) == 2) {
    scanf("%s",s);
    ll y=0,x=0;
    int n = strlen(s);
    REP(i,n) {
      d[i] = strchr("URDL", s[i]) - s;
    }
	ix = 0;
	iy = 0;
    vx[ix++] = 0;
	vy[iy++] = 0;
    REP(i,n) {
      y += dy[d[i]];
      x += dx[d[i]];
	  vy[iy++] = y;
      vx[ix++] = x;
    }
    ll Y = y;
    ll X = x;
    bool ok = 0;
    REP(i,n) {
      REP(j,n) {
        ll yy = vy[j];
        ll xx = vx[j];
        ll y = b-yy;
        ll x = a-xx;
        if (Y && y % Y == 0) {
          if (X*(y/Y) == x) {
            ok = 1;
          }
        }
        if (Y == 0 && y == 0) {
          if (x == 0 || (X && x % X == 0)) {
            ok = 1;
          }
        }
      }
    }
    printf("%s\n",ok?"Yes":"No");
  }
}


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
typedef long long ll;

const int dy[] = {1,0,-1,0};
const int dx[] = {0,1,0,-1};

int d[100];
char s[105];
int vx[105], vy[105];
int ix, iy;
int main() {
	int a,b;
	while(scanf("%d%d", &a, &b) == 2) {
		scanf("%s",s);
		ll y=0,x=0;
		int n = strlen(s);
		REP(i,n) {
			d[i] = strchr("URDL", s[i]) - s;
		}
		ix = 0;
		iy = 0;
		vx[ix++] = 0;
		vy[iy++] = 0;
		REP(i,n) {
			y += dy[d[i]];
			x += dx[d[i]];
			vy[iy++] = y;
			vx[ix++] = x;
		}
		ll Y = y;
		ll X = x;
		int ok = 0;
		REP(i,n) {
			REP(j,n) {
				ll yy = vy[j];
				ll xx = vx[j];
				ll y = b-yy;
				ll x = a-xx;
				if (Y && y % Y == 0) {
					if (X*(y/Y) == x) {
						ok = 1;
					}
				}
				if (Y == 0 && y == 0) {
					if (x == 0 || (X && x % X == 0)) {
						ok = 1;
					}
				}
			}
		}
		printf("%s\n",ok?"Yes":"No");
	}
}


#include<stdio.h>
#define MAX_N 50000007

int sieve[MAX_N];
int primes[MAX_N];
int main() {
	for( int i=2; i*i<MAX_N; ++i )
		if( sieve[i] == 0 ) {
			primes[++primes[0]] = i;
			sieve[i] = i;
			for( int j = i*i; j<MAX_N; j += i )
				if( sieve[j] == 0 )
					sieve[j] = i;
		}
	long long n;
	scanf("%lld", &n);
	int ans = 0;
	while( n ) {
		++ans;
		if( n < MAX_N ) {
			n -= sieve[n]; continue;
		}
		int isprime = 1;
		for( long long i=1; isprime && i<=primes[0] && primes[i]*primes[i] <= n; ++i )
			if( n%primes[i] == 0 )
				n -= primes[i], isprime = 0;
		if( isprime )
			n = 0;
	}
	printf("%d\n", ans);
}


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


#include<stdio.h>
#define MX 1000
long long int p,k,k1=1,sm,A[MX];
int main(){
    int i,j,sz;
    long long int ims;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    scanf("%lld%lld",&p,&k);
    for(sz=0;;sz+=2){
        sm+=(k-1)*k1;
        A[sz]=k-1;
        if(sm>=p){break;}
        k1*=k;
        k1*=k;
    }
    p=sm-p;
    for(i=0;i<=sz;i++){
        ims=p%k;
        p=p/k;
        if(i%2==0){A[i]-=ims;}
        else{A[i]=ims;}
    }
    printf("%d\n",sz+1);
    for(i=0;i<=sz;i++){
        printf("%lld ",A[i]);
    }
}


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

int poww(int m, int n)
{
    int t = 1;
    int i;

    if(n == 0)
        return 1;
    else
        for(i = 1; i <= n; i++)
            t *= m;

    return t;
}

int main()
{
    char hour[6];
    char minu[6];
    int h, m;
    int hmax, mmax;
    int min, max;
    int left;
    int flag;
    int i, j;
    char c;
    int hflag, mflag;

    i = 0;
    while(1) {
        c = getchar();
        if(c != ':') {
            hour[i] = c;
            i++;
        }
        else {
            hour[i] = 0;
            break;
        }
    }

    i = 0;
    while(1) {
        c = getchar();
        if(c != '\n') {
            minu[i] = c;
            i++;
        }
        else {
            minu[i] = 0;
            break;
        }
    }

    h = strlen(hour);
    m = strlen(minu);

    i = 0;
    while(hour[i] == '0') {
        h--;
        i++;
    }
    hflag = i;

    i = 0;
    while(minu[i] == '0') {
        m--;
        i++;
    }
    mflag = i;

    if(m == 1 && h == 1)
        if(hour[hflag] >= '0' && hour[hflag] <= '9' || hour[hflag] <= 'N' && hour[hflag] >= 'A') {
            printf("-1\n");
            return 0;
        }
    if(m == 0 && h == 0) {
        printf("-1\n");
        return 0;
    }

    if(h > 0) {
        hmax = 2;
        for(i = hflag; i < hflag + h; i++) {
            if(hour[i] <= '9' && hour[i] >= '0')
                hmax = hmax > (hour[i] - '0' + 1) ? hmax : (hour[i] - '0' + 1);
            else
                hmax = hmax > (hour[i] - 'A' + 11) ? hmax : (hour[i] - 'A' + 11);
        }
    }
    else
        hmax = -1;

    if(m > 0) {
        mmax = 2;
        for(i = mflag; i < mflag + m; i++) {
            if(minu[i] <= '9' && minu[i] >= '0')
                mmax = mmax > (minu[i] - '0' + 1) ? mmax : (minu[i] - '0' + 1);
            else
                mmax = mmax > (minu[i] - 'A' + 11) ? mmax : (minu[i] - 'A' + 11);
        }
    }
    else
        hmax = -1;

    min = hmax > mmax ? hmax : mmax;
    mmax = mmax == -1 ? mmax : min;
    hmax = hmax == -1 ? hmax : hmax;

    if(h == 1)
        hmax = -1;
    else if(hmax != -1) {
        flag = 0;
        while( 1 ) {
            left = 23;
            for(i = hflag + h - 1, j = 0; i >= hflag; i--, j++) {
                if(hour[i] <= '9' && hour[i] >= '0')
                    left -= (hour[i] - '0') * poww(hmax, j);
                else
                    left -= (hour[i] - 'A' + 10) * poww(hmax, j);
            }

            if(left >= 0) {
                flag = 1;
                hmax++;
            }
            else if(flag == 0) {
                printf("0\n");
                return 0;
            }
            else {
                hmax--;
                break;
            }
        }
    }

    if(m == 1)
        mmax = -1;
    else if(mmax != -1) {
        flag = 0;
        while( 1 ) {
            left = 59;
            for(i = mflag + m - 1, j = 0; i >= mflag; i--, j++) {
                if(minu[i] <= '9' && minu[i] >= '0')
                    left -= (minu[i] - '0') * poww(mmax, j);
                else
                    left -= (minu[i] - 'A' + 10) * poww(mmax, j);
            }

            if(left >= 0) {
                flag = 1;
                mmax++;
            }
            else if(flag == 0) {
                printf("0\n");
                return 0;
            }
            else {
                mmax--;
                break;
            }
        }
    }

    if(hmax != -1 && mmax != -1)
        max = hmax > mmax ? mmax : hmax;
    else
        max = mmax == -1 ? hmax : mmax;

    for(i = min; i <= max; i++) {
        if(i == max)
            printf("%d\n", i);
        else
            printf("%d ", i);
    }

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int value(char c){
    if(c>='0' && c<='9') return c-'0';
    else if(c>='A' && c<='Z' ) return c-'A'+10;
    else {
        printf("Error radix\n");
        return -1;
    }
}
int valueR(char* num,int radix){
    int i;
    int rt=0;
    for(i=0;i<strlen(num);i++){
        rt=rt*radix+value(num[i]);
    }
    return rt;
}
int main(){
    char num[20];
    char num1[6];
    char num2[6];

    int max=0;
    int i,j;
    int check,c;

    scanf("%s",num);
    check=0;//count 0
    c=0;
    for(i=0;num[i]!=':';i++){
        if(num[i]!='0') check=1;
        if(check==1){
            num1[c++]=num[i];
            if(value(num[i])>max) max= value(num[i]);
        }
    }
    num1[c]='\0';

    check=0;
    c=0;
    i++;
    for(;num[i]!='\0';i++){
        if(num[i]!='0') check=1;
        if(check==1) {
            num2[c++]=num[i];
            if(value(num[i])>max) max= value(num[i]);
        }
    }
    num2[c]='\0';

    //printf("\n%s:%s %d\n",num1,num2,max);

    //caculate
    if(strlen(num1)==1&&strlen(num2)==1) printf("-1\n");
    else{
        i=max+1;
        check=0;
        while(1){
            //check radix i
            if(valueR(num1,i)<24 && valueR(num2,i)<60){
                printf("%d ",i);
                check=1;
            }else{
                if(check==0) printf("0");
                break;
            }
            i++;
        }
    }
    return 0;
}


#include <stdio.h>

int main(void){
    int n, k;
    int i, remain;
    scanf("%d %d", &n, &k);
    remain = 240-k;
    if(remain>=5){
        for(i=1; k>=0; i++){
            remain -= i*5;
        }
        printf("%d", i);
    }else{
        printf("0");
    }

    return 0;
}


#import<stdio.h>
#define swap(a,b) (a)^=(b)^=(a)^=(b)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
long long gcd(long long a,long long b) {return !b?a:gcd(b,a%b);}
int main()
{
	long long l1,r1,t1,l2,r2,t2;
	scanf("%lld%lld%lld%lld%lld%lld",&l1,&r1,&t1,&l2,&r2,&t2);
	if (l1>l2) swap(l1,l2),swap(r1,r2),wwap(t1,t2);
	long long k=gcd(t1,t2),p,ans=0;
	p=(l2-l1)/k;l1+=k*p,r1+=k*p;
	ans=max(ans,(min(r1,r2)-max(l1,l2))+1);
	l1+=k,r1+=k;
	ans=max(ans,(min(r1,r2)-max(l1,l2))+1);
	printf("%lld\n",ans);
	return 0;
}


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

int main()
{
	long long int n ,k , count = 0, temp , sum = 0 , eaten = 0 ,tries , o;
	scanf ("%lld %lld" ,&n , &k );
	if (k > 1)
	{
		while ( sum < k )
		{
			count ++;
			sum = sum + count;
		}
		while (1)
		{
			if ( sum == k && count == n)
			{
				printf("%lld" , eaten);
				return 0;
			}
			count ++;
			sum = sum - 1;
			eaten ++;
		}
	}
	else if (k == 0)
		{
			eaten = 1;
			tries = 2;
			while(1)
			{

				if (tries == n)
				{
					printf("%lld" , eaten);
					return 0;
				}
				eaten = eaten + 2 + count;
				tries = tries + 3 + count;
				count ++;
			}
		}
		else
		{
			eaten = 0;
			tries = 1;
			while(1)
			{

				if (tries == n)
				{
					printf("%lld" , eaten);
					return 0;
				}
				eaten = eaten + 2 + count;
				tries = tries + 3 + count;
				count ++;
			}
		}

}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#define LiangJiaJun main
using namespace std;
int n,m,k,ans=1,Reduc_;

int LiangJiaJun(){
    scanf("%d%d%d",&n,&m,&k);
    m -= n;
    Reduc_ = 1;
    if(m == 0) return puts("1"),0;
    while(m>0){
        if(k+ans<=n)++Reduc_;
        if(k-ans>=1)++Reduc_;
        m -= Reduc_;
        ++ans;
    }
    printf("%d\n",ans);
    return 0;
}


# include <stdio.h>
# define N 51
int main ()
{
    char *direccion=(char*)calloc(N,sizeof(char));
    scanf("%s", &direccion);
    int i=0, longitud, band=0;
    longitud=strlen(direccion);
    if (direccion[0]=='h')
    {
        printf("http://");
        i=4;
    }
    if (direccion[0]=='f')
    {
        printf("ftp://");
        i=3;
    }
     while(direccion[i]!= '\0' )
     {
        printf("%c", direccion[i]);
        if (direccion[i+1]=='r' && direccion[i+2]=='u' && band==0)
        {
            printf(".ru");
            band=1;
            if (direccion[i+3]!= '\0'){
                printf("/");
            }
        i=i+2;
        }
    i++;
    }
    return 0;
}


#include<stdio.h>
int main ()
{
	int c[5];
	int j;

	for (j=0;j<10;j++)    c[j]=j;

	for (j=0;j<10;j++)    printf("%d",c[j]);

	return 0;

}


#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 40000000
#define M 1000000000
typedef long long ll;
typedef struct _list{
    ll val;
    struct _list *next;
} list;
ll n, k1, k2, k1a[22], k2a[22], p, f, flag=1;
list *map[N], *k1h, *k2h, *k1t, *k2t;
void push(ll u, ll v){
    list *ptr1=(list *) malloc(sizeof(list)), *ptr2=(list *) malloc(sizeof(list));
    ptr1->val=v;
    ptr2->val=u;
    ptr1->next=map[u];
    ptr2->next=map[v];
    map[u]=ptr1;
    map[v]=ptr2;
}
void enqueue(ll p, ll val){
    list *ptr=(list *) malloc(sizeof(list));
    ptr->val=val;
    ptr->next=NULL;
    if (p==1){
        if (!k1h)
            k1h=k1t=ptr;
        else{
            k1t->next=ptr;
            k1t=ptr;
        }
    }
    else{
        if (!k2h)
            k2h=k2t=ptr;
        else{
            k2t->next=ptr;
            k2t=ptr;
        }
    }
}
ll dequeue(ll p){
    ll val;
    if (p==1){
        val=k1h->val;
        k1h=k1h->next;
        if (!k1h)
            k1t=NULL;
    }
    else{
        val=k2h->val;
        k2h=k2h->next;
        if (!k2h)
            k2t=NULL;
    }
    return val;
}
bool empty(ll p){
    return p==1?(k1h==NULL):(k2h==NULL);
}
int main(){
    scanf("%lld", &n);
    scanf("%lld", &k1);
    for (ll i=1; i<=k1; i++)
        scanf("%lld", &k1a[i]), enqueue(1, k1a[i]);
    scanf("%lld", &k2);
    for (ll i=1; i<=k2; i++)
        scanf("%lld", &k2a[i]), enqueue(2, k2a[i]);
    for (ll i=1; i<N; i++){
        if (!empty(1)&&!empty(2)){
            f++;
            ll v1=dequeue(1), v2=dequeue(2);
            push(v1, v2);
            if (v2>v1)
                enqueue(2, v1), enqueue(2, v2);
            else
                enqueue(1, v2), enqueue(1, v1);
        }
        else if (empty(1)){
            printf("%lld 2", f);
            return 0;
        }
        else if (empty(2)){
            printf("%lld 1", f);
            return 0;
        }
    }
    printf("-1");
}


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

void merge(int arr[], int l, int m, int r) {
	int i = 0; // Initial index of first subarray
	int j = 0; // Initial index of second subarray
	int k = l; // Initial index of merged subarray
	int n1 = m - l + 1;
	int n2 = r - m;

	/* create temp arrays */
	int L[n1], R[n2];

	/* copy data to temp arrays L[] and R[] */
	for (int i = 0; i < n1; i++)
		L[i] = arr[l + i];
	for (int j = 0; j < n2; j++)
		R[j] = arr[m + 1 + j];

	/* merge the temp arrays back into arr[l..r] */
	while (i < n1 && j < n2) {
		if (L[i] <= R[j]) {
			arr[k] = L[i];
			i++;
		} else {
			arr[k] = R[j];
			j++;
		}
		k++;
	}

	/* copy the remaining elements of L[] || R[], if there are any */
	while (i < n1) {
		arr[k] = L[i];
		i++;
		k++;
	}
	while (j < n2) {
		arr[k] = R[j];
		j++;
		k++;
	}
}

void mergeSort(int arr[], int l, int r) {
	if (l < r) {
		int m = l + (r - l) / 2;

		// sort first and second halves
		mergeSort(arr, l, m);
		mergeSort(arr, m + 1, r);

		merge(arr, l, m, r);
	}
}

int main(void) {
    int n, d, min[10000];
    int k = 0; // for array min[]
    scanf("%d %d", &n, &d);
    int a[n];
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);

    mergeSort(a, 0, n - 1);

    if (d == 0 || (a[n - 1] - a[0] =< d) || n == 1) {
        printf("0\n");
        return 0;
    }

    for (int i = n - 1; i >= 0; i--) {
        for (int j = i; j >= 0; j--) {
            if (a[i] - a[j] == d) {
                min[k++] = (n - 1) - (i - j + 1);
            }
        }
    }

    mergeSort(min, 0, k - 1);

    printf("%d\n", min[0] + 1);
    return 0;
}


#include<stdio.h>
int main()
{
    int a, b, i, count, n, temp;
    int j;
    int num[6];
    for(i = 0; i < 4; i++){
        scanf("%d", &num[i]);
    }
    for( j = 1, count = 0; j <= 1000000000 ; j++){
        for(i = 0; i < 4; i++){
            if(num[i] == j){
                count++;
                break;
            }
        }

    }
    n = 4 - count;
    printf("%d", n);

    return 0;
}


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

int main(void)
{
	int n;
	scanf("%d",&n);
	if(n==1 || n==2)
		printf("%d",n);
	else if(n<6)
		printf("3");
	else if(n<9)
		printf("4");
	else if(n<14)
		printf("5");
	else if(n<19)
		printf("6");
	else if(n<26)
		printf("7");
	else if(n<32)
		printf("8");
	else if(n<41)
		printf("9");
	else if(n<50)
		printf("10");
	else if(n<61)
		printf("11");
	else if(n<72)
		printf("12");
	else if(n<85)
		printf("13");
	else if(n<98)
		printf("14");
	else
		printf("15");

	return 0;
}


#include<stdio.h>
int main()
{
	int arr[5],i,sum=0;
	scanf("%d %d %d %d %d",&arr[0],&arr[1],&arr[2],&arr[3],&arr[4]);
	for(i=0;i<5;i++)
		{
			sum=sum+arr[i];
		}

	if(sum==0)
		{printf("-1");
                return;
                 }
	if(sum%5==0&&sum!=0)
		printf("%d",sum/5);
	else
		printf("-1");
}


#include<stdio.h>

int main(){
	long a,b;
	scanf("%ld%ld",&a,&b);
	int counter =0;
	while(a!=b){
		counter++;
		if(a>b){
			int temp;
			temp=a;a=b;b=temp;
		}
		b = b-a;
	}

	printf("%ld\n",counter+1);
}


#include<stdio.h>
#include<string.h>
int main(){
char s[100];
 char name[100][100]={"Danil", "Olya", "Slava", "Ann", "Nikita"};
int f=1,i,j,k,ql,nl;
 scanf("%s",&s);
 ql=strlen(s);
 for(i=0;i<5;i++)
   {
   	nl=strlen(name[i]);
   	for(j=0;j<ql-nl+1;j++)
   	{
   	  for(k=0;k<l2;k++)
                 { if(s[j+k] != name[i][k])
                   { f=0;}
                 }
        }
   }

if(f)
 {printf("YES");}
else
 {printf("NO");}

}


/*
 * 6.10.c
 *
 * Copyright 2019 HP <HP@DESKTOP-L2C0F23>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *
 *
 */

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

int main(int argc, char **argv)
{
	int check(char[],char[]);

char s[100];
 char name[100][100]={"Danil", "Olya", "Slava", "Ann", "Nikita"};
 int i,j,k,l1,l2,c=0;
 scanf("%s",&s);
l1=strlen(s);
 for(i=0;i<5;i++)
   {
   	l2=strlen(name[i]);
   	for(j=0;j<l1-l2+1;j++)
   	{
   		int f=1;
   		for(k=0;k<l2;k++) if(s[j+k] != name[i][k]) f=0;

   		if(f) c++;
	   }
   }

if(c==1) printf("YES");
else printf("NO");

}
	return 0;
}


#include<stdio.h>
#define true 1
#define false 0
int isComp[1000002]={0};
void sieve(long long int N)
{
	long long int ans=1;
	long long int i;
	for(i=2;i*i<=N;i++)
	{
		if(isComp[i]==false)
		{
			if(N%i==0)
			{
				//long long int temp=N;
				while(N%i==0)
				{
					N/=i;
				}
				ans*=i;
			}
			long long int j=2*i;
			while(j<=N)
			{
				isComp[j]=true;
				j+=i;
			}
		}
	}
	if(N)
		ans*=N;
	printf("%lld\n",ans);
}
int main()
{
	long long int N;

	scanf("%lld",&N);
	sieve(N);
	return 0;
}


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

int main(void)
{
    char c;
    char a[9];
    bool s = true;

    int i = 0;
    while(i < 9 && (c = getchar()))
        if(c == 'x')
            a[i++] = 1;
        else if(c == '.')
            a[i++] = 0;

    for(int i = 0; s && i < 9; i++)
        if(a[i] != a[8 - i])
                s = false;

    printf("%s", s ? "YES" : "NO");

    return 0;
}


#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int v=n;

    int in=1;
       while(v!=1)
       {
           if(v%in!=0)
           {
               v=v-in;
               in=1;
           }
           in++;
       }
        printf("%d\n",v);

    return 0;
}


#include<stdio.h>
#define INF 1000000009
int max(int x,int y){
    if(x>y){
        return x;
    }
    return y;
}
int min(int x, int y){
    if(x>y){
        return y;
    }
    return x;
}
int main(){
    int n,m,i,j,a,b,cnt1=INF,cnt2=INF,cnt3=INF,cnt4=INF,ans1=INF,ans2=INF,ans3=INF,ans4=INF,i,j,ret;
    scanf("%d%d%d%d%d%d",&n,&m,&i,&j,&a,&b);
    if((i-1)%a!=0){
        if((n-i)%a!=0){
            if((j-1)%b!=0){
                if((m-j)%b!=0){
                    printf("Poor Inna and pony!\n");
                    return 0;
                }
            }
        }
    }
    if((i-1)%a==0){
        cnt1=(i-1)/a;
    }
    if((n-i)%a==0){
        cnt2=(n-i)/a;
    }
    if((j-1)%b==0){
        cnt3=(j-1)/b;
    }
    if((m-j)%b==0){
        cnt4=(m-j)/b;
    }
    if((cnt1-cnt3)%2==0 && cnt1!=INF && cnt3!=INF){
        ans1=max(cnt1,cnt3);
    }
    if((cnt1-cnt4)%2==0 && cnt1!=INF && cnt4!=INF){
        ans2=max(cnt1,cnt4);
    }
    if((cnt2-cnt3)%2==0 && cnt2!=INF && cnt3!=INF){
        ans3=max(cnt2,cnt3);
    }
    if((cnt2-cnt4)%2==0 && cnt2!=INF && cnt4!=INF){
        ans4=max(cnt2,cnt4);
    }
    if(ans1==INF && ans2==INF && ans3==INF && ans4==INF){
        printf("Poor Inna and pony!\n");
        return 0;
    }
    i=min(ans1,ans2);
    j=min(ans3,ans4);
    ret=min(i,j);
    printf("%d\n",ret);
    return 0;
}


#include<stdio.h>
typedef long long ll;
int c[40][40];
int main()
{
    for (int i=0;i<=30;i++)
    {
        c[i][0]=c[i][i]=1;
        for (int j=1;j<i;j++)
            c[i][j]=c[i-1][j-1]+c[i-1][j];
    }
    long long int n,m,t,i;
    scanf("%I64d%I64d%I64d",&n,&m,&t);
    ll ans=0;
    for (i=4;i<=n;i++)
    {
        int p=t-i;
        if (p<1)
            break;
        if (p>m)
            continue;
        ans+=ll(c[n][i])*c[m][p];
    }
    printf("%I64d\n",ans);
    return(0);
}


#include <stdio.h>

#define min(a, b) (a < b ? a : b)

long long power( int a, int b ) {
	if( b == 0 ) return 1;

	long long res = power(a, b/2);
	res *= res;

	if( b % 2 ) res *= a;
	return res;
}

long long length( long long N ) {
	int l = 0;

	if( N == 0 ) return 1;

	while( N ) {
		N /= 10;
		l++;
	}

	return l;
}

long long first( long long N ) {
	return N / power(10, length(N)-1);
}

long long middle( long long N ) {
	return (N - first(N) * power(10, length(N)-1)) / 10 + 1;
}

long long nways( int N ) {
	long long res = 0;

	res = min(9, N);
	res += min(N,99) / 11;

	if( length(N) > 2 ) {
		int i;

		for( i = 3; i < length(N); i++ )
			res += 9 * power(10, i-2);

		for( i = 1; i < first(N); i++ )
			res += power(10, length(N)-2);

		res += middle(N);

		int last = N % 10;
		if( first(N) > last ) res--;
	}

	return res;
}

int main( void ) {
	long long L, R;
	scanf("%lld %lld", &L, &R);

	printf("%lld\n",nways(R) - nways(L-1));

	return 0;
}


#include <stdio.h>
int main()
{
int n,k,i=0,j,a[15];
int sum=0;
scanf("%d %d",&n,&k);
for(j=0;j<n;j++)
scanf("%d",&a[j]);
for(j=0;j<n;j++)
sum=sum+a[j];
while(1)
{
	float l;
	l=n/2;
	if(sum<(k*n-l))
	{
		i++;
		sum=sum+k;
		n++;
		//printf("%d",i);
	}
	else
	break;
}
printf("%d",i);
}


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

int main() {
	long long **dp;
	int n, h;
	int i, j;

	scanf("%d%d", &n, &h);
	dp = malloc(sizeof(long long *) * n);
	dp[0] = malloc(sizeof(long long) * 1);
	dp[0][0] = 1;
	if (n == 1 && h == 1) {
		printf("1\n");
		return 0;
	}
	for (i = 1; i < n; i++) {
		dp[i] = malloc(sizeof(long long) * (i + 1));
		for (j = 0; j <= i; j++) {
			dp[i][j] = i - 1;
			if (j == 0)
				dp[i][j] += 2 * dp[i - 1][j];
			else if (j == i)
				dp[i][j] = 2 * dp[i - 1][j - 1];
			else
				dp[i][j] += 2 * dp[i - 1][j - 1];
			if (i == n - 1 && j == h - 1) {
				printf("%lld\n", dp[i][j]);
				return 0;
			}
		}
	}
	return 0;
}


#include <stdio.h>
#define N 1002
#define MOD 1000000007

typedef long long typec;

int n, m, k;
typec ftable[N];
typec facmod[1000001];

typec extend_gcd(typec a, typec b, typec *x, typec *y)
{
	if(!b) return *x = 1, *y = 0, a;
	typec res = extend_gcd(b, a % b, x, y), tmp = *x;
	*x = *y, *y = tmp - (a / b) * (*y);
	return res;
}

typec inverse(typec a, typec m)
{
	typec x, y;
	y = extend_gcd(a, m, &x, &y);
	while(x < 0) x += m;
	return x;
}

typec pow_mod(typec x, typec k, typec m)
{
	typec res = 1;
	while(x %= m, k) {
		if(k&1) res *= x, res %= m;
		x *= x, k >>= 1;
	}
	return res;
}

int mymin(int x, int y)
{
	return x < y? x : y;
}

typec combines(int i, int j)
{
	if(i < j) return 0;
	return facmod[i] * inverse(facmod[j], MOD) % MOD * inverse(facmod[i - j], MOD) % MOD;
}

void init()
{
	int i, j;
	facmod[0] = 1;
	for(i = 1; i <= 1000000; i++) {
		facmod[i] = facmod[i - 1] * i;
		facmod[i] %= MOD;
	}
	typec sum = 0;
	ftable[1] = 1;
	for(i = 2; i <= n; i++) {
		ftable[i] = pow_mod(i, n, MOD) + MOD;
		sum = 0;
		for(j = 1; j < i; j++) {
			sum += combines(i, j) * ftable[j] % MOD;
			sum %= MOD;
		}
		ftable[i] -= sum;
		ftable[i] %= MOD;
	}
}

typec calc()
{
	int i, j, m1, m2;
	typec res = 0, tmp, stmp;
	m1 = mymin(n, k);
	for(i = 0; i <= m1; i++) {
		tmp = combines(k, i) * pow_mod(i, (m - 2) * n, MOD) % MOD;
		m2 = mymin(n - i, (k - i) / 2);
		stmp = 0;
		for(j = 0; j <= m2; j++) {
			if(!i && !j) continue;
			stmp += combines(k - i, j) * combines(k - i - j, j) % MOD * ftable[i + j] % MOD * ftable[i + j] % MOD;
			stmp %= MOD;
		}
		res += tmp * stmp % MOD;
		res %= MOD;
	}
	return res;
}
int main()
{
	scanf("%d%d%d", &n, &m, &k);
	init();
	printf("%lld\n", calc());
	return 0;
}


#include<stdio.h>
int main()
{
	char a,b;
	long long int n;
	scanf("%c%c%lld",&a,&b,&n);
	n=n%4;
	if n%2==0:
		printf("undefined");
	else:
		if (n==1)
			if (a=='^')
				if (b=='>')
					printf("cw");
				else
					printf("ccw");
			if (a=='>')
				if (b=='V')
					printf("cw");
				else
					printf("ccw");
			if (a=='V')
				if (b=='<')
					printf("cw");
				else
					printf("ccw");
			if (a=='<')
				if (b=='^')
					printf("cw");
				else
					printf("ccw");
		if (n==3)
			if (a=='^')
				if (b=='<')
					printf("cw");
				else
					printf("ccw");
			if (a=='>')
				if (b=='^')
					printf("cw");
				else
					printf("ccw");
			if (a=='V')
				if (b=='>')
					printf("cw");
				else
					printf("ccw");
			if (a=='<')
				if (b=='V')
					printf("cw");
				else
					printf("ccw");
	return 0;
}


#include<stdio.h>
int main()
{
    char s[101];
    int len,i,a=0,b=0;
    scanf("%s",s);
    len=strlen(s);
    for(i=0;i<len;i++){
    if(s[i]=='-'){
        a++;
    }
    if(s[i]=='o'){
        b++;
    }
    }
    if(a%b==0)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


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

int main() {
	char s[120];
	int o=0,d=0,I,len;
	scanf("%s",s);
        len=strlen(s)
	for(I=0;I<len;I++) {
		if(s[I]== 'o') o++;
		else d++;
}
            if(o==0 || d%o==0)
             printf("YES");
else printf("NO");
}


#include<stdio.h>
#include<string.h>
int main(){
    int i,j,k,l;
    char r[102];
    scanf("%s",r);
    j=strlen(r);
    k=0;
    l=0;
    for(i=0;i<j;i++){
        if(r[i]=='-'){
            k++;
        }
        else if(r[i]=='o'){
            l++;
        }
    }
    if(k%l==0){
        printf("YES");
    }
    else if(k%l!=0){
        printf("NO");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    char a[105];
    int b,count=0,cou2=0,i;
    scanf("%s",&a);
    b=strlen(a);
    for(i=0;i<b;i++)
    {
        if(a[i]=='o')
            count++;
        if(a[i]=='-')
            cou2++;
    }
    if(cou2%count==0)
        printf("YES\n");
    else
        printf("NO\n");
}


A=list(input())
p=len([x for x in A if x=='o'])
l=len(A)-p
if l%p==0:
    print("YES")
else:
    print("NO")


#include <stdio.h>
#include<string.h>
int main() {
	char str[101];
	scanf("%s",str);
	int l=strlen(str);
	int d=0,p=0;
	for(int i=0;i<l;i++){
	    if(str[i]=='o')p++;
	    else d++;
	}
	else if(d==0||p==0)printf("YES");
	else if(d%p==0)printf("YES");
	else printf("NO");
	return 0;
}


#include <stdio.h>

int main()
{
    char s[100];
    int p=0,l=0,i=0;
    scanf("%s",s);
    while(s[i]!='\0');
    {
        if(s[i]=='o')
            p++;
        else
        l++;
        i++;
    }
    if(l==0||p==0)
    printf("YES");
    else if(l%p==0)
    printf("YES");
    else
    printf("NO");
    return 0;

}


//
//  main.c
//  test1
//
//  Created by Abdallah Elerian on 3/23/16.
//  Copyright © 2016 Abdallah. All rights reserved.
//

#include <stdio.h>

int main() {
    int a1,a2,n=0;
    scanf("%d",&a1);
    scanf("%d",&a2);
    while (a1!=0 || a2!=0) {
        if(a1<a2)
        {
            a1++;
            a2=a2-2;
        }
        else{
            a2++;
            a1=a1-2;
        }
        n++;

    }
    printf("%d",n);

    return 0;
}


#include<stdio.h>
int n, d, c = 101;
char p[101];

void home(int i, int cont){
	if(cont < c){
		if(i == n-1)
			c = cont;
		else{
			int tam = (d+i<n)? d+i: n-1;
			for(int j=tam; j>i; j--)
				if(p[j]=='1')
					home(j, cont+1);
		}
	}
}

int main(){
	scanf("%d%d", &n, &d);
	scanf("%s", &p);
	home(0,0);
	printf("%d\n", c==101? -1:c);

	return 0;
}


#include<stdio.h>
typedef long long unsigned llu;
int dicmal();
int main()
    {
        llu x,y;
        x=dicmal();

        y=dicmal();

        printf((x<y)?"\n<":(x>y)?"\n>":"\n=");
        return 0;
    }
int dicmal()
    {
        llu r=0;
        llu x,bx,d;
        scanf("%u%u",&x,&bx);
        for(;x>0;x--)
        {
            scanf("%u",&d);
            r=r*bx+d;
        }

        return r;
    }