#include<stdio.h>
#include<stdlib.h>
int main()
{
    char s[3],t[3],xy,yx;
    int a,b,c,d,x,i=0;
    gets(s);
    gets(t);
    xy=s[0];
    a=s[1];
    yx=t[0];
    b=t[1];
    c=abs(xy - yx);
    d=abs(a-b);
    if(c>d){
        printf("%d\n",c);
        x=c;
    }
    else{
        printf("%d\n",d);
        x=d;
    }
    while(i<=x)
    {
        if(xy<yx)
        {
        if(a<b)
        {
            printf("RU\n");
            a++;
            xy++;
        }
        else if(a>b)
        {
            printf("RD\n");
            a--;
            xy++;
        }
        else
        {
            printf("R\n");
            xy++;
        }
        i++;
        }
        else if(xy>yx){
           if(a<b)
        {
            printf("LU\n");
            a++;
            xy--;
        }
        else if(a>b)
        {
            printf("LD\n");
            a--;
            xy--;
        }
        else
        {
            printf("L\n");
            xy--;
        }
        i++;
        }
        else{
            if(a<b)
            {
                printf("U\n");
                a++;
            }
            else if(a>b){
                printf("D\n");
                a--;
            }
            i++;
        }
    }

}


#include <stdio.h>
int main(){
    long long n,l,r;
    scanf("%lli %lli %lli",&n,&l,&r);
    long long min;
    if(l>1) min = (n-l)+((1<<l)-1);
    else min = n;
    long long max = 1;
    if(r>=n){
        max = (1<<n)-1;
    }
    else{
        max = (1<<r)-1;
        n -= r;
        r--;
        max += n*(1<<r);
    }
    printf("%lli %lli",min,max);
    return 0;
}


#include <stdio.h>

int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        int x, y = 0, le = 0, k = 0;

        scanf("%d", &x);

        while(x > 0)
        {
            le++;
            y = x % 10;
            x = x / 10;
        }
        k = (y - 1) * 10;

        for(int i = 1; i <= le; i++)
        {
            k += i;
        }
        printf("\n %d", k);
    }

    return 0;
}


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void factorize(int64 n,int64 *f,int *resLen){
  f[0]=1;
  int len=1;
  int64 k;
  for(k=2;k*k<=n;k++){
    if(n%k==0){
      int c=0;
      while(n%k==0){
	c++;
	n/=k;
      }
      int64 mul;
      int i;
      for(i=1,mul=k;i<=c;i++,mul*=k){
	int j;
	for(j=0;j<len;j++){
	  f[i*len+j]=f[j]*mul;
	}
      }
      len*=c+1;
    }
  }
  if(n>1){
    int i;
    for(i=0;i<len;i++){
      f[len+i]=f[i]*n;
    }
    len*=2;
  }
  *resLen=len;
  return;
}

int cmp(const void *a,const void *b){
  int64 p=*(int64 *)a;
  int64 q=*(int64 *)b;
  return p==q?0:p-q<0?-1:1;
}

void run(void){
  int64 a,b;
  scanf("%lld%lld",&a,&b);
  int64 factorA[20000];
  int lenA=0;
  factorize(a,factorA,&lenA);
  int64 factorB[20000];
  int lenB=0;
  factorize(b,factorB,&lenB);
  int64 s=a+b;
  int64 factorS[40000];
  int lenS=0;
  factorize(s,factorS,&lenS);
  qsort(factorA,lenA,sizeof(int64),cmp);
  qsort(factorB,lenB,sizeof(int64),cmp);
  qsort(factorS,lenS,sizeof(int64),cmp);
  /*
  {
  int i;
  printf("%lld : ",a);for(i=0;i<lenA;i++) printf("%lld ",factorA[i]);printf("\n");
  printf("%lld : ",b);for(i=0;i<lenB;i++) printf("%lld ",factorB[i]);printf("\n");
  printf("%lld : ",s);for(i=0;i<lenS;i++) printf("%lld ",factorS[i]);printf("\n");
  }
  */
  int ai=0;
  int bi=0;
  int64 min=2*a+2*b+2;
  int i;
  for(i=0;i<=(lenS+1)/2 && factorS[i]*factorS[i]<=s;i++){
    int64 r=factorS[i];
    while(ai<lenA && factorA[ai]<=r) ai++;
    while(bi<lenB && factorB[bi]<=r) bi++;
    if(s/r>=a/factorA[ai-1] || s/r>=b/factorB[bi-1]){
      min=2*(r+s/r);
    }
  }
  printf("%lld\n",min);
}

int main(void){
  run();
  return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    int x1,x2,y1,y2;
    while(~scanf("%d%d%d%d",&x1,&y1,&x2,&y2))
    {
        int n1,n2,n3,tmp1,tmp2;
        printf("%d ",!(!abs(x1-x2))+!(!abs(y1-y2)));
        tmp1 = abs(x1-x2);
        tmp2 = abs(y1-y2);
        if((abs(tmp1-tmp2))%2!=0&&abs(tmp1-tmp2)>0)
            printf("0 ");
        else
        {
            if(tmp1==tmp2)
                printf("1 ");
            else
                printf("2 ");
        }
        printf("%d\n",tmp1>tmp2?tmp1:tmp2);
    }
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n,i;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	if(n==1&&a[n-1]!=15&&a[n-1]!=0)
	{
		printf("-1");
		exit(0);
	}
	if(a[n-1]!=15&&a[n-1]!=0)
	{
		if(a[n-1]>a[n-2])
			printf("UP");
		else
			printf("DOWN");
	}
	else if(a[n-1]==15)
		printf("DOWN");
	else
		printf("UP");
}


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

int table[2][3000][3000];
long long g, x, y, z;
#define MAXINT 0x7fffffff

int nextg(){
	int ret=g;
	g=(g*x+y)%z;
	return ret;
}

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

int msb(int a){
	a|=a>>1;
	a|=a>>2;
	a|=a>>4;
	a|=a>>8;
	a|=a>>16;
	return (a+1)>>1;
}

int main(){
	int i, j, k, n, m, a, b, tren=0, prev, l;
	long long sum=0;
	scanf("%d %d %d %d %I64d %I64d %I64d %I64d", &n, &m, &a, &b, &g, &x, &y, &z);
	for(i=0;i<n;++i)
		for(j=0;j<m;++j)
			table[0][i][j]=nextg();
	for(k=0;(1<<k)<msb(a);++k){
		prev=k&1;
		tren=!prev;
		for(i=0;i+(1<<k)<n;++i){
			for(j=0;j<m;++j){
				table[tren][i][j]=min(table[prev][i][j], table[prev][i+(1<<k)][j]);
			}
		}
	}
	for(l=0;(1<<l)<msb(b);++l){
		prev=(l+k)&1;
		tren=!prev;
		for(i=0;i+(1<<k>>1)<n;++i){
			for(j=0;j+(1<<l)<m;++j){
				table[tren][i][j]=min(table[prev][i][j], table[prev][i][j+(1<<l)]);
			}
		}
	}
	for(i=0;i+a-1<n;++i){
		for(j=0;j+b-1<m;++j){
			sum+=(long long)(min(min(min(
								table[tren][i][j],
								table[tren][i+(a^msb(a))][j]),
								table[tren][i][j+(b^msb(b))]),
								table[tren][i+(a^msb(a))][j+(b^msb(b))]));
		}
	}
	printf("%I64d\n", sum);
	return 0;
}


#include<stdio.h>
main()
{
    int s,v1,v2,t2,t1,a,b,c,d;
    while(scanf("%d%d%d%d%d",&s,&v1,&v2,&t1,&t2)!=EOF)
    {
        a=(s*v1)+(2*t1);
        b=(s*v2)+(2*t2);
        if(a>b)
        printf("Second\n");
        else if(a<b)
            printf("First\n");
        else
            printf("Friendship\n");
    }
    return 0;
}


#include<stdio.h>
main(){
    char s[]="GBIV";
    int n,i=0;
    scanf("%d",&n);
    printf("ROY");
    while(i<n-3) {putchar(s[i%4]);i++;}
    return 0;
}


#define rep(v, a, b) for (v = (a); v <= (b); v++)
#define repi(n) for (i = 0; i < (n); i++)
#define repj(n) for (j = 0; j < (n); j++)
#define repk(n) for (k = 0; k < (n); k++)

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

int main()
{
	int i, j, k, len, max = 0;
	char str[110];

	scanf("%s", str);
	len = strlen(str);
	repi(len) rep(j, i+1, len-1)
	{
		k = 0;
		while (k < len && str[i+k] == str[j+k]) k++;
		if (max < k) max = k;
	}
	printf("%d\n", max);
	return 0;
}


#include <stdio.h>
#include <math.h>
int main(){
	int x,y,n;
	scanf("%d %d %d\n",&x,&y,&n);
	double res = (double)0/1, input = (double)x/y;
	int a = 0, b = 1;
	int num = 0;
	int i;
	for(i = 1; i <= n; i++){
		while(1){
			double cur = (double)num/i;
			if(fabs(cur-input) < fabs(res-input)){
				res = cur;
				a = num;
				b = i;
			}
			if(num <= x && fabs((double)(num+1)/i - input) < fabs(cur-input) ){
				num++;
			}
			else{	break;	}
		}

	}
	printf("%d/%d\n",a,b);

	return 0;
}


#include <stdio.h>
long long n,res,a=1;
int main()
{
	for (scanf("%I64d",&n);a<n;res+=(n-1)/a*(a-(a>>1)),a<<=1ll);
	printf("%I64d\n",res);
	return 0;
}


#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <float.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
#include <complex.h>
#include <errno.h>
#include <time.h>
int n,m,i,j,k,min,ans[25],f[25],s,l,t[25];
struct u
{
	int a,b;
}a[25],b[25];

int main()
{
	scanf("%d %d",&n,&m);
	for (i=1;i<=n;i++) scanf("%d %d",&a[i].a,&a[i].b);
	for (i=1;i<=m;i++) scanf("%d %d",&b[i].a,&b[i].b);
	memset(ans,0,sizeof(ans));
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=9;j++) t[j]=ans[j];
		for (j=1;j<=m;j++)
		{
			memset(f,0,sizeof(f));
			f[a[i].a]++;
			f[a[i].b]++;
			f[b[j].a]++;
			f[b[j].b]++;
			for (l=1,s=0;l<=9;l++)
			if (f[l])
			{
				s++;
				if (f[l]==2) k=l;
			}
			if (s==3) ans[k]++;
		}
		memset(f,0,sizeof(f));
		for (j=1,s=0;j<=9;j++)
		if (t[j]<ans[j]) s++;
		if (s>1)
		{
			puts("-1");
			exit(0);
		}
	}
	memset(ans,0,sizeof(ans));
	for (i=1;i<=m;i++)
	{
		for (j=1;j<=9;j++) t[j]=ans[j];
		for (j=1;j<=n;j++)
		{
			memset(f,0,sizeof(f));
			f[a[j].a]++;
			f[a[j].b]++;
			f[b[i].a]++;
			f[b[i].b]++;
			for (l=1,s=0;l<=9;l++)
			if (f[l])
			{
				s++;
				if (f[l]==2) k=l;
			}
			if (s==3) ans[k]++;
		}
		for (j=1,s=0;j<=9;j++)
		if (t[j]<ans[j]) s++;
		if (s>1)
		{
			puts("-1");
			exit(0);
		}
	}
	memset(f,0,sizeof(f));
	for (i=1,s=0;i<=9;i++)
	if (ans[i])
	{
		s++;
		k=i;
	}
	if (s==0) puts("-1");
	else if (s==1) printf("%d\n",k);
	else puts("0");
	return 0;
}


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


#include<stdio.h>

long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}

int main(){
  long long n,a[128],res=1;
  scanf("%lld",&n);
  for(int i=1;i<=n;i++){scanf("%lld",&a[i]);}
  for(int i=1;i<=n;i++){
    long long len=1,pt=a[i];
    while(len<1000){
      if(pt==i){break;}
      len++;
      pt=a[pt];
    }
    if(len==1000){puts("-1");return 0;}
    if(len%2==0){len/=2;}
    res=lllcm(len,res);
  }
  printf("%lld\n",res);
}


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

#define N	100000

int jj[N], pp[N], dd[N], mn;

void match(int i) {
	while (dd[i] == 1) {
		int j = jj[i], tmp;

		if (pp[i] == i || dd[j] == 1)
			tmp = pp[i], pp[i] = pp[j], pp[j] = tmp;
		else
			mn -= 2;
		jj[i] ^= j, dd[i] = 0, jj[j] ^= i, dd[j]--;
		i = j;
	}
}

int main() {
	int n, h, i, j;

	scanf("%d", &n);
	for (h = 0; h < n - 1; h++) {
		scanf("%d%d", &i, &j), i--, j--;
		jj[i] ^= j, dd[i]++, jj[j] ^= i, dd[j]++;
	}
	for (i = 0; i < n; i++)
		pp[i] = i;
	mn = (n - 1) * 2;
	for (i = 0; i < n; i++)
		match(i);
	printf("%d\n", mn);
	for (i = 0; i < n; i++)
		printf("%d ", pp[i] + 1);
	printf("\n");
	return 0;
}


#include<stdio.h>
// Merges two subarrays of arr[].
// First subarray is arr[l..m]
// Second subarray is arr[m+1..r]
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    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 (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    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[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

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

/* l is for left index and r is right index of the
   sub-array of arr to be sorted */
void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        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 fu(int a,int b){
if(a-b<=0){
    return 0;
}
else{
    return a-b;
}
}
int main()
{
    int n,m,arr[100],i,l,r,mid,in,j,sum=0,w;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++){
        scanf("%d",&arr[i]);
    }
    mergeSort(arr,1,n);
    l=1;r=n;
    while(l<=r)
    {sum=0;w=n;
        mid=(l+r)/2;
        (n%mid==0)?(in=n/mid):(in=(n/mid)+1);
        for(i=0;i<in;i++){
            for(j=1;j<=mid&&w>=1;j++){
                sum=sum+fu(arr[w],i);
                w--;//printf("%d ",sum);
            }
        }//printf("\n%d_%d ",mid,sum);
        if(sum==m){l=mid;r=mid;
            break;
        }
        else if(sum<m){
            l=mid+1;
        }
        else{
            r=mid-1;
        }
    }
   if(l<=n&&r>=0){
       if((l+r)%2!=0)
        printf("%d",(l+r)/2+1);
        else
            printf("%d",(l+r)/2);
   }

   else printf("-1");
    return 0;
}


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

int main()
{

    char str[100];
    scanf("%s", str);
    int l,i;
    l = strlen(str);
    for(i=l-1;i>=0;i--){
        if(str[i]=='0'){
            str[i] = '\0';
        }
        else break;
    }
    int l1,flag;
    l1 = strlen(str);
    flag=0;
    for(i=0;i<l1;i++){
        if(str[i] != str[l1-i-1]){
            flag = 1;
            break;
        }
    }
    if(flag) printf("NO\n");
    else printf("YES\n");
    return 0;
}


#include <stdio.h>

int main()
{
    unsigned long long a, b;
    unsigned long long c = 0;

    scanf("%I64u %I64u", &a, &b);

    while ((a > 0) && (b > 0))
    {
        if (a >= b)
        {
            c += a / b;
            a = a % b;
        }
        else
        {
            c += b / a;
            b = b % a;
        }
    }

    printf("%I64u", c);

    return 0;
}

/*
a = 10   b = 7
a = 10 % 7

*/


#include <stdio.h>

int main(){
	int a[1000];
	int n, i, elimina, dif, difMax = 0, difMin = 1000;

	scanf("%d", &n);

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

	for(elimina = 1; elimina < n-1; elimina++){
		difMax = 0;

		for(i = 1; i < n; i++){
			if(elimina == i){
				dif = a[i+1] - a[i-1];
				i++;
			}
			else{
				dif = a[i] - a[i-1];
			}

			if(dif > difMax) difMax = dif;
		}

		if(difMax < difMin) difMin = difMax;
	}

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

	return 0;
}


#include<stdio.h>

int main(){

    int w, h, k;

    scanf("%d %d %d",&w, &h, &k);

    printf("%d",2*k*(w + h) - 4*k*(2*k - 1));

    return 0;
}


#include <stdio.h>

enum {
    BOUND = 10000 * 1010,
    MAXP = 1000
};

char notPrime[BOUND];
int conv[BOUND];

int countPower(int x, int n) {
    int res = 0;
    while(n % x == 0) {
        n /= x;
        res++;
    }
    return res;
}

void init() {
    int i, j;
    for(i = 1; i < BOUND; i++)
        conv[i] = 1;
    notPrime[0] = notPrime[1] = 1;
    for(i = 2; i < BOUND; i++) {
        if(notPrime[i]) continue;
        conv[i] *= i;
        for(j = 2; i * j < BOUND; j++) {
            notPrime[i * j] = 1;
            if(countPower(i, j) % 2 == 0)
                conv[i * j] *= i;
        }
    }
}

int main() {
    int i, n, a;
    long long ans = 0;
    init();
    scanf("%d %d", &a, &n);
    for(i = a; i < a + n; i++) {
        ans += conv[i];
    }
    printf("%I64d\n", ans);
    return 0;
}


#include <stdio.h>

int mod_inv(int a, int p){
	int y = p-2;
	int res = 1;
	while(y!=0){
		if(y&1){
			res = ((long long)res * a)%p;
		}
		a = ((long long)a*a)%p;
		y = y>>1;
	}
	return res;
}

int main(void) {
	// your code goes here
	int n,c,i;
	scanf("%d %d",&n,&c);
	int res = c;
	int prev = c;
	int p = 1000003;
	for(i=2; i<=n ;i++){
		prev = ((((long long)(c+i-1)*prev)%p)*mod_inv(i,p))%p;
		res = (res + prev)%p;
	}
	printf("%d\n",res);
	return 0;
}


#include <stdio.h>

int main(){
  int n,t,k,d;
  int oven1;
  int i;
  int totalCakes = 0;
  int isO2Built = 0;
  scanf("%d %d %d %d",&n, &t, &k, &d);
  oven1 = ((n/k)+(n%k!=0))*t;
  for(i = 0; i < oven1; i++){
    if(i == d) isO2Built = 1;
    if(i%t == 0 && i > 0) totalCakes += k;
    if(isO2Built && (i-d)%t == 0 && (i-d) > 0) totalCakes += k;
    if(totalCakes >= n) break;
    }
    // printf("cakes: %d, time: %d\n",totalCakes, i );
  if(i < oven1) printf("YES\n" );
  else printf("NO\n" );
}


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

int main()
{
    int a;
    int q,r,sum;

    scanf("%d",&a);

    do
    {
            sum=0;
        q=a;

        while(q!=0)
        {
            r=q%10;
            q=q/10;
            sum=sum+r;
        }

        if(sum%4==0)
            {
            printf("%d\n",a);
        }
        a=a+1;
    }
    while(sum%4!=0);

    return 0;
}


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

void swap(int *n, int *m)
{
    int temp = *n;
    *n = *m;
    *m = temp;
}

int main()
{
    char str[101];
    scanf("%s", str);

    int len = strlen(str);
    int nums[101];
    for(int i = 0; i < len; i += 2) {
        nums[i] = str[i] - '0';
    }

    for(int i = 0; i < len; i += 2) {
        for(int k = i + 2; k < len; k += 2) {
            if(nums[i] > nums[k]) {
                swap(&nums[i], &nums[k]);
            }
        }
    }

    for(int i = 0; i < len; i += 2) {
        printf("%d", nums[i]);
        if(i != len - 1) printf("+");
    }

    return 0;
}


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

    scanf("%d %d %d %d %d",&c,&d,&n,&m,&k);
    int z;
    if((m*n-k)>0)
    z=m*n-k;
    else
    z=0;
    float s=n*1.0/c;
    float a=1.0/d;
    int ans=0,t;
    if(a>=s)
    {
        printf("%d",d*(z));
    }

    else
    {
        t=z%n;
        if(d*t<c)
        ans+=d*t;
        else
        ans+=c;
        ans+=(z/n)*c;
        printf("%d",ans);
    }

    return 0;
}


#include<stdio.h>
#include<math.h>
char cmd[100005];
int main()
{
	int n;
	int l = 0, r = 0;
	int sum = 0;
	scanf("%d", &n);
	scanf("%s", cmd);
	for (int i = 0;i < n;i++)
	{
		if (cmd[i] == 'L')l++;
		else r++;
	}
	if (l != r)sum = l + r +1;
	else sum = l + r + 1;
		printf("%d", sum);
	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=0;i<k;i++)
	{
		printf("0");
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
     char a,b,c,d,e;
     int i,j,k,l;
     scanf("%d:%d",&i,&j);
     l=0;
    while(i%10!=j/10 || i/10!=j%10)
    {
         l++;
         j++;
         if(j>59)
         {
              j=0;
              i++;
         }
          if(i==24)
         break;
    }
     printf("%d",l);
}


#include<stdio.h>
int main()
{
    long long int n,m,k,max,min,rem,ans,var;
    scanf("%lld%lld%lld", &n, &m, &k);
    if(n>=m)
    {
        max = n;
        min = m;
    }
    else
    {
        max = m;
        min = n;
    }
    if(k<max)
    {
        if((min%(k+1)==0) && (k < min))
        {
            ans = (min/(k+1))*max;
        }
        else if(max%(k+1)==0)
            ans = (max/(k+1))*min;
        else
        {
            //if(k<min)
            ans = (min/(k+1))*max;
           // else
            //{
            var = (max/(k+1))*min;
            if(var>ans)
                ans = var;
            //}
        }
    }
    else
    {
        rem = k - (max-1);
//        printf("%lld\n", rem);
        if(rem < min)
        {
            if(min%(rem+1)==0)
                ans = min/(rem + 1);
            else
                ans = min/(rem + 1);
        }
        else
            ans = -1;
    }
    printf("%lld\n", ans);
    return 0;
}


#include<stdio.h>

long long mod = 998244353;

long long dp[2002][2002];

long long mod1(long long n, long long k){

    int i, j;

    for(i = 0; i < n; i++){

        dp[i][0] = 1;

        dp[i][1] = i;

        dp[i][i] = 1;
    }
    for(i = 2; i < n; i++){

        for(j = 1; j < i; j++){

            dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % mod;
        }
    }
    return dp[n - 1][k];
}
long long bigmod(long a, long p){

    long long res = 1;

    long long x = a;

    while(p){

        if(p & 1){

            res = (res*x) % mod;
        }
        x = (x*x)%mod;

        p = p >> 1;
    }
    res = (res*(a + 1))%mod;

    return res;
}
int main(){

    long long n,m,k;

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

    long long r = (mod1(n,k)*bigmod(m - 1, k))%mod;

    printf("%lld",r);

    return 0;
}


#include <stdio.h>

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

int main(void) {
	int p1; int p2; int p3; int p4; int a; int b;

	scanf("%d%d%d%d%d%d", &p1, &p2, &p3, &p4, &a, &b);

	int min_p = p1;
	min_p = min(min_p, p2);
	min_p = min(min_p, p3);
	min_p = min(min_p, p4);

	int result = 0;
	if (a < min_p) {
		result = min_p - a;
		if (b < min_p) result = b - a + 1;
	}

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

	return 0;
}


#include<stdio.h>

int answer(long long int  bx,long long int  by,long long int  cx,long long int  cy);

int main(void){
  struct vector{
    long long int  x;
    long long int  y;
  }a,b,c,d;
  int flg,j,k;

  scanf("%I64d %I64d",&a.x,&a.y);
  scanf("%I64d %I64d",&b.x,&b.y);
  scanf("%I64d %I64d",&c.x,&c.y);

  flg=0;
  flg+=answer(b.x-a.x,b.y-a.y,c.x,c.y);
  flg+=answer(b.x+a.y,b.y-a.x,c.x,c.y);
  flg+=answer(b.x+a.x,b.y+a.y,c.x,c.y);
  flg+=answer(b.x-a.y,b.y+a.x,c.x,c.y);

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

int answer(long long int  bx,long long int  by,long long int  cx,long long int  cy){
  long long int  tmp;
  if(cx==0 && cy==0){
    if(bx==0 && by==0) return 1;
    return 0;
  }
  if(cx==0){
    if(bx%cy==0 && by%cy==0) return 1;
    return 0;
  }else if(cy==0){
    if(bx%cx==0 && by%cx==0) return 1;
    return 0;
  }else{
    tmp=cx*cx+cy*cy;
    if((bx*cx+by*cy)%tmp==0 && (by*cx-bx*cy)%tmp==0) return 1;
    return 0;
  }
  return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int i,pos=0;
    char s[100009],s1[1000009];
    scanf("%s",s);
    int l=strlen(s);
    for(i=0;i<l;i++)
    {
        if(((int)s[i]-97)<=pos && pos<26)
        {
            s1[i]=(char)(97+pos);
            pos++;
        }
        else
            s1[i]=s[i];
    }
    if(pos>=26)
    printf("%s",s1);
    else
    printf("-1");
    return 0;
}


#include<stdio.h>
int main(){
int i,j,m,max=0,min,A[100],n,a;
scanf("%d",&n);
scanf("%d",&m);
for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i]>max){
        max=A[i];
    }
}
a=m;
i=0;
while(m>0&&i<n){
    if(A[i]!=max){
        if(m>=(max-A[i])){
            m=m-(max-A[i]);
            //printf("%d %d\n",A[i],m);
        }
        else if(m<(max-A[i])){
            A[i]=A[i]+m;
            m=0;
        }

    }
     min=max;
    i=i+1;
}

//printf("%d %d",min,m);
if(m!=0)
    min=min+m/n;
if(m%n!=0)
    min=min+1;
printf("%d %d",min,max+a);
}


#include <stdio.h>

int main() {
	long long n, x;

	scanf("%lld", &n);
	for (x = 2; x * x <= n; )
		if (n % (x * x) == 0)
			n /= x;
		else
			x++;
	printf("%lld\n", n);
	return 0;
}


/*
ID: mohamma73
LANG: C
TASK: crypt1
*/

#include"stdio.h"
#include"stdlib.h"
#include"ctype.h"
#include"math.h"
#include"string.h"
struct element{
	int val;
	int indx;
};
struct person{
	int id;
	int nd;
	int nl;
	int like[15];
	int dis[15];
};
struct farmer{
	int p;
	int c;
};
void inc(int *a,int n){
	int i;
	if(a[0]!=2){
		a[0]++;
		return;
	}
	for(i=0;i<n && a[i]==2;i++)
		a[i]=0;
	if(i<n)
		a[i]++;
}
int cmp(char *s,char *t){
	int n=strlen(s);
	int m=strlen(t);
	int i,j;
	for(i=0,j=0;i<n && j<m && s[i]==t[j];i++,j++);
	if(s[i]>t[j])
		return 1;
	else if(s[i]<t[j])
		return -1;
	else
		return 0;

}
int getword(char *s,int n){
	int i;
	char c;
	while(isspace(c=getchar()));
	for(i=0;i<n && !isspace(c);i++,c=getchar())
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
int fgetword(char *s,int n,FILE *fp){
	int i;
	char c;
	while(isspace(c=getc(fp)));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getc(fp))
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
long long atll(char *s){
	long long n=0;
	int i;
	for(i=0;s[i]!='\0';i++){
		n*=10;
		n+=(s[i]-'0');
	}
	return n;
}
int Bsear(char *s,char words[][13],int n){
	int l=0;
	int h=n;
	int mid;
	while(l<h){
		mid=(l+h)/2;
		if(cmp(words[mid],s)==0)
			return 1;
		else if(cmp(words[mid],s)==1){
			h=mid;
		}else
			l=mid+1;
	}
	return -1;
}
void func(int *n,int base,int num){
	int i=0;
	while(num/base!=0){
		n[i++]=num%base;
		num/=base;
	}
	n[i++]=num;
	n[i++]=20;
}
int pal(int *n){
	int i,j;
	for(i=0;n[i]!=20;i++);
	for(j=0;j<i/2 && n[j]==n[i-j-1];j++);
	if(j==i/2)
		return 1;
	return 0;
}
int ispal(char *s, int i, int j){
	int k;
	for(k=0;k<((j-i+1)/2) && s[i+k]==s[j-k];k++);
	if(k==(j-i+1)/2)
		return 1;
	return 0;
}
void insort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++){
		j=i;
		while(j>0 && a[j]<a[j-1]){
			temp=a[j-1];
			a[j-1]=a[j];
			a[j]=temp;
			j--;
		}
	}
}
char lower(char c){
	return c<'a'?c+('a'-'A'):c;
}
void merge(struct element *a,int l,int q,int n){
	int n1=q-l+1;
	int i,j,k;
	int n2=n-q;
	struct element L[n1+1];
	struct element R[n2+1];
	for(i=0;i<n1;i++)
		L[i]=a[l+i];
	for(i=0;i<n2;i++)
		R[i]=a[q+i+1];
	L[n1].val=100002;
	R[n2].val=100002;
	i=0;
	j=0;
	for(k=l;k<=n;k++)
		if(L[i].val<=R[j].val){
			a[k]=L[i];
			i++;
		}else{
			a[k]=R[j];
			j++;
		}
}
void mergesort(struct element *a,int l,int n){
	if(n>l){
		int q=(l+n)/2;
		mergesort(a,l,q);
		mergesort(a,q+1,n);
		merge(a,l,q,n);
	}
}
int isOkay(int a,int *s , int n){
	if(a<100 || a>=1000)
		return 0;
	int c,i;
	while(a/10>0){
		c=0;
		for(i=0;i<n;i++)
			if(a%10==(s[i]-'0')){
				c=1;
				break;
			}
		if(!c)
			return 0;
		a/=10;
	}
	c=0;
	for(i=0;i<n;i++)
		if(a==(s[i]-'0')){
			c=1;
			break;
		}
	if(c)
		return 1;
	return 0;
}
int isOkay2(int a,int *s , int n){
	if(a<1000 || a>=10000)
		return 0;
	int c,i;
	while(a/10>0){
		c=0;
		for(i=0;i<n;i++)
			if(a%10==(s[i]-'0')){
				c=1;
				break;
			}
		if(!c)
			return 0;
		a/=10;
	}
	c=0;
	for(i=0;i<n;i++)
		if(a==(s[i]-'0')){
			c=1;
			break;
		}
	if(c)
		return 1;
	return 0;
}
void sort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;

		}
}
void fun(int n,char *s){
	int i=0;
	for(i=0;n/10!=0;i++,n/=10)
		s[i]=n%10+'0';
	s[i++]=n+'0';
	s[i]='\0';
}
void sortIn(int *a,int *indx,int n){
	int t1;
	int i,j;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
			t1=a[j-1];
			a[j-1]=a[j];
			a[j]=t1;
			t1=indx[j-1];
			indx[j-1]=indx[j];
			indx[j]=t1;
		}
}
int valid(int *a,int l,int r,int n){
	int f=0;
	if(l>0 && a[l-1]>a[r])
		f=1;
	if(a[l+1]<a[r])
		f=1;
	if(a[r-1]>a[l])
		f=1;
	if(r<n-1 && a[r+1]<a[l])
		f=1;
	if(f)
		return 0;
	return 1;
}
void change(char *stripe,int *colors,int idx,int k){
	int j=0;
	if(idx==1){
		if(stripe[0]-'A'>0)
			stripe[0]=colors[stripe[0]-'A'-1];
		else
			stripe[0]=colors[stripe[0]-'A'+1];
		return ;
	}
	for(j=0;j<idx;j+=2){
		if(stripe[j]-'A'>0){
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j+1]!=colors[stripe[j]-'A'-1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j]-'A'<k-1)
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'-2];
		}else{
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'+2];
		}
	}
}
int invite(struct person *nom[],int n,struct person *acq[],struct person *inac[],int m,struct person *invite[]){
	int i,j,idx=0,z;
	for(i=0;i<n;i++){
		for(j=0;j<nom[i]->nl;j++){
			for(z=0;z<m && inac[z]->id!=nom[i]->like[j];z++);
			if(z==m){
				inac[m++]=acq[nom[i]->like[j]];
				invite[idx++]=acq[nom[i]->like[j]];
			}
		}

	}
	return idx;
}
int feasible(struct person *a[],int n){
	int i,j,k;
	int flag=1;
	for(i=0;flag && i<n;i++)
		for(j=0;flag && j<a[i]->nd;j++)
			for(k=0;flag &&k<n;k++){
				if(a[k]->id==a[i]->dis[j]){
					flag=0;
					break;
				}
			}
	if(i==n)
		return 1;
	return 0;
}
main(){
	char s[200];
	struct person *acquin[15];
	struct person *nominee[15];
	struct person *invited[15];
	struct person *inac[15];
	int i,j;
	int greatest=0;
	int from,to;
	int m,q,r;
	getword(s,20);
	int n=atoi(s);
	for(i=0;i<n;i++){
		acquin[i]=(struct person *)malloc(sizeof(struct person));
		acquin[i]->nd=0;
		acquin[i]->nl=0;
		acquin[i]->id=i;
	}
	getword(s,20);
	int k=atoi(s);
	for(i=0;i<k;i++){
		getword(s,20);
		from=atoi(s)-1;
		getword(s,20);
		to=atoi(s)-1;
		acquin[from]->like[acquin[from]->nl++]=to;
		acquin[to]->like[acquin[to]->nl++]=from;
	}
	getword(s,20);
	k=atoi(s);
	for(i=0;i<k;i++){
		getword(s,20);
		from=atoi(s)-1;
		getword(s,20);
		to=atoi(s)-1;
		acquin[from]->dis[acquin[from]->nd++]=to;
		acquin[to]->dis[acquin[to]->nd++]=from;
	}
	for(i=0;i<n;i++){
		inac[0]=acquin[i];
		m=1;
		nominee[0]=acquin[i];
		r=1;
		q=invite(nominee,r,acquin,inac,m,invited);
		m+=q;
		while(q>0){
			if(!feasible(inac,m))
				break;
			for(j=0;j<q;j++)
				nominee[j]=invited[j];
			r=q;
			q=invite(nominee,r,acquin,inac,m,invited);
			m+=q;
		}
		if(q==0){
			if((m-q)>greatest)
				greatest=(m-q);
		}
	}
	printf("%d",greatest);
	return 0;
}


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

int main()
{
    long long n,y,prey,ans=0,i;
    scanf("%I64d",&n);
    if(n==0)
        printf("1\n");
    else
    {
        prey = sqrt(n*n - 1);
        ans++;
        for(i=2;i<=n;i++)
        {
            y = sqrt(n*n-i*i);
                    //printf("%lld %lld prevy y\n",prey,y);
            if(y==prey)
                ans++;
            else
                ans += prey - y;
            prey = y;
        }
        ans--;
                        //printf("%lld check\n",ans);
        ans *= 4;

        ans += 4;
        printf("%I64d\n",ans);
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
long long int cmpfunc( const void *a, const void *b) {
  return *(long long int*)a - *(long long int *)b;
}

int main()
{
 long long int test,d,n,x,i,sum=0,count=0,j,flag=0,p,y,m,max=0,o,g,r,k, a[1002];
 scanf("%lld%lld",&n,&m);
max=abs(n-m);
if(max>=2){
if(max/2>=max/3){
    printf("2");
}else{
   printf("3");
    }

}else{
 printf("%lld",n);
}

    return 0;
}


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

int main()
{
    int a, b, n, rnds=0;
    scanf("%d %d %d",&n,&a,&b);
    if ((a <= n/2 && b > n/2) || (n == 2) || (b <= n/2 && a > n/2) ) {
            //printf("%d,%d,%d",n,a,b);
        printf("Final!");
    } else {
        while (a != b) {
            a = ceil (a/2.0);
            b = ceil (b/2.0);
    //printf("%d,%d,%d",n,a,b);
            rnds++;
        }
        printf("%d",rnds);
    }

    return 0;
}


#include<stdio.h>
int main()
{
    int i,k,n,a,min=0;
    scanf("%d %d",&n,&k);
    for (i=0;i<n;i++)
    {
        scanf("%d",&a);
        if ((k%a==0)&&(a>min))
        {
            min=a;

        }
    }
    printf("%d",k/min);
    return 0;
}


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


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

#define N	1000000

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

int aa[N + 1], kk[N + 1];

void init() {
	int a, b, k;

	memset(aa, -1, (N + 1) * sizeof *aa);
	for (a = 2; a <= N; a++) {
		if (aa[a] != -1)
			continue;
		b = 1, k = 0;
		while (1) {
			if (b > N / a)
				break;
			b *= a, k++;
			aa[b] = a, kk[b] = k;
		}
	}
}

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

long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}

long long solve(int n, int m, int a, long long b, int k, int k_, long long k1, int l) {
	if (b <= n)
		return solve(n, m, a, b * a, k + 1, k_, k1, l) + solve(n, m, a, b * a, k + 1, k_ == -1 ? k : k_, lcm(k1, k), l + 1);
	else
		return l == 0 ? 0 : ((long long) m * k_ / k1) * (l % 2 == 1 ? 1 : -1);
}

int main() {
	int n, m, a;
	long long ans;

	init();
	scanf("%d%d", &n, &m);
	ans = 1;
	for (a = 2; a <= n; a++)
		if (aa[a] == a)
			ans += solve(n, m, a, a, 1, -1, 1, 0);
	printf("%lld\n", ans);
	return 0;
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int max=0;
int a[10];
int p[100];
typedef struct
{
	int val;
	int mvrg;
	int thrg;
}Ch;
typedef Ch CA[4];
int movethrow(CA,int);
int search(int pe)
{
	int i,t;
	for (i=1;i<45;i++)
	{
		if (p[i]>0)
		{
			t=p[i];
			while (t)
			{
				if ((t%10)==pe)
					return i;
				t=t/10;
			}
		}
	}
}
int change(int pe,int pos)
{
	int t;
	t=search(pe);
	p[t]=0;
	p[pos]=pe;

}
int tr(CA C,int pe)
{
	int i,j;
	int f,m,r,t[4];
	int temp;
	t[1]=search(1);
	t[2]=search(2);
	t[3]=search(3);
	m=t[pe];
	temp=p[m];
	f=m-C[pe].thrg;
	r=m+C[pe].thrg;
	if (r>max)
		max=r;
	if (f<=0)
		f=1;
	for (i=f;i<=r;i++)
	{
		if (i!=m&&p[i]==0&&
			(abs(i-t[1])==1||abs(i-t[2]==1)||abs(i-t[3])==1||i==r))
		{

			p[i]=temp/10;
			p[m]=temp%10;
			for (j=1;j<=9;j++)
			{

				if (a[j]==0)
				{
					a[j]=1;a[0]++;
					movethrow(C,j);
					a[j]=0;a[0]--;
				}
			}
			p[i]=0;
			p[m]=temp;
		}
	}
	return 0;
}
int mv(CA C,int pe)
{
	int i,j;
	int f,m,r,t[4];
	t[1]=search(1);
	t[2]=search(2);
	t[3]=search(3);
	int temp;
	temp=t[pe];
	m=t[pe];
	t[pe]=t[3];
	t[3]=temp;
	f=m-C[pe].mvrg;
	r=m+C[pe].mvrg;
	if (r>max)
		max=r;
	if (f<=0)
		f=1;
	for (i=f;i<=r;i++)
	{
		if (i!=m&&p[i]==0&&
			(abs(i-t[1])<=2||abs(i-t[2]<=2)||abs(i-t[3])<=1||i==r))
		{
			change(pe,i);

			for (j=1;j<=9;j++)
			{
				if (a[j]==0)
				{
					a[j]=1;a[0]++;
					movethrow(C,j);
					a[j]=0;a[0]--;
				}
			}
		}
	}
	change(pe,m);
	return 0;
}

int movethrow(CA C,int fr)
{
	int i,j;
	int rt;
	if (fr%3==1)
	{
		rt=fr/3+1;
		if (a[fr+1]==1&&a[fr+2]==0)
		{
			return 0;
		}
		else if (p[search(rt)]>10)
		{
			return 0;
	 	}
		else
		{
			mv(C,rt);

			return 0;
		}

	}
	if (fr%3==2)
	{
		int px;
		rt=fr/3+1;
		px=search(rt);
		if (p[px]>10)
		{
			return 0;
		}
		else if (p[px-1]>0)
		{
			int temp;
			p[px]+=p[px-1]*10;
			temp=p[px-1];
			p[px-1]=0;
			for (j=1;j<=9;j++)
			{
				if (a[j]==0)
				{
					a[j]=1;a[0]++;
					movethrow(C,j);
					a[j]=0;a[0]--;
				}
			}
			p[px]=rt;
			p[px-1]=temp;
		}
		else if (p[px+1]>0)
		{
			int temp;
			p[px]+=p[px+1]*10;
			temp=p[px+1];
			p[px+1]=0;
			for (j=1;j<=9;j++)
			{
				if (a[j]==0)
				{
					a[j]=1;a[0]++;
					movethrow(C,j);
					a[j]=0;a[0]--;
				}
			}
			p[px]=rt;
			p[px+1]=temp;
			return 0;
		}
		else
		{
			return 0;
		}
	}
	if (fr%3==0)
	{
		rt=fr/3;
		int px;
		px=search(rt);
		if (a[fr-1]==0)
		{
			return 0;
		}
		else if (p[px]%10!=rt)
		{
			return 0;
		}
		else
		{
			tr(C,rt);
			return 0;
		}
	}
}
int main()
{
	CA C;
	int i,j;
	for (i=1;i<100;i++)
	{
		p[i]=0;
	}
	for (i=1;i<=3;i++)
	{
		scanf("%d %d %d",&C[i].val,&C[i].mvrg,&C[i].thrg);
		p[C[i].val]=i;
	}
	for (i=0;i<=9;i++)
	{
		a[i]=0;
	}
	for (i=1;i<=9;i++)
	{
		a[i]=1;a[0]++;
		movethrow(C,i);
		a[i]=0;a[0]--;
	}

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


#include <stdio.h>

long long min(long long x,long long y){return (x<y?x:y);}
int n,prev;
char s[111];
long long k,store[111][111];

void Main(){
    scanf("%d %lld",&n,&k);
    scanf("%s",s);
    store[0][0] = 1;
    for(int i = 0;i<n;i++){
        prev = -1;
        for(int j = 0;j<i;j++) if(s[i]==s[j]) prev = j;
        for(int j = n;j>=1;j--){
            for(int k = prev;k<i;k++){
                store[j][i+1] += store[j-1][k+1];
                store[j][i+1] = min(store[j][i+1],1000000000000ll);
            }
        }
    }
    long long Ans = 0,total = 0;
    for(int i = n;i>=0;i--){
        total = 0;
        for(int j = 0;j<=n;j++) total += store[i][j];
        if(total<k){
            k-=total;
            Ans+=(n-i)*total;
        }
        else{

            Ans += (n-i)*k;
            k = 0;
            break;
        }
    }
    if(k==0) printf("%lld\n",Ans);
    else puts("-1");
    return;
}
int main(){
    Main();
    return 0;
}


#include <stdio.h>
#include<math.h>
int main()
{
    int n,m,x;
    scanf("%d%d",&n,&m);
    x=m%(int)pow(2,n);
    printf("%d\n",x);
    return 0;
}


/*
 * LS4.2.c
 *
 * Copyright 2019  <examuser@11CPU0126L>
 *
 * 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>

int main(int argc, char **argv)
{
	int n,S,min;
	scanf("%d%d",&n,&S);
	min=((S-1)/n)+1;
	printf("%d",min);
	return 0;
}


#include "stdio.h"

int main()
{
	int T,S,q,count=0;
	scanf("%d%d%d",&T,&S,&q);
	while (S<T)
	{
		count++;
		S*=q;
	}
	printf("%d",count);
	return 0;
}


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

int cmpfunc (const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}

int main()
{
    int size,max,i,counter=0,buffer=0,j,k;
    scanf("%i %i",&size,&max);
    int array[size];
    int array2[size];

    for(i=0;i<size;++i)
    {
        scanf("%i",&array[i]);
        array2[i]=array[i];
    }

    qsort(array,size,sizeof(int),cmpfunc);

    i=0;
    while(counter<=max && i<=size)
    {
        counter += array[i];
        ++buffer;
        ++i;
    }

    printf("%i\n",buffer-1);

    if(buffer-1==0)
        return 0;
    //*******************

    for(j=0;j<buffer-1;++j)
    {
        for(k=0;k<size;++k)
        {
            if(array[j]==array2[k])
            {
                array2[k] = -1;
                printf("%i ",k+1);
                break;
            }
        }
    }

    printf("\n");

    return 0;
}


#include <stdio.h>

int main()
{
	int n,m,x,y;
	scanf("%d %d %d",&n,&x,&y);
	n=n/2;
	if ((x == n || x == n + 1) && (y == n || y == n + 1)) printf("NO\n"); else printf("YES\n");

	return 0;
}


#include<stdio.h>
#define min(a,b) a<b?a:b
int main()
{
    long long n,k,a,b,s=0,c=0,mn;
    scanf("%lld%lld%lld%lld",&n,&k,&a,&b);
    mn=(n-1)*a;
    if(k==1||k>n)
        printf("%lld\n",mn);
    else
    {
        while(n>1)
        {
            if(n%k==0)
            {
                s+=min(b,a*(n-(n/k)));
                n/=k;
            }
            else
            {
                s+=((n%k)*a);
                n-=(n%k);
            }
            //printf("%lld ",n);
        }
        if(n==0)
            s-=a;
        printf("%lld\n",min(mn,s));
    }
}


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

#define N	50
#define M	(N * (N - 1))
#define N_	(N + 2)
#define M_	(M * 3 + 2)
#define X	100000
#define INF	0x3f3f3f3f

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

int oo[1 + M * 2], oh[1 + M * 2], _ = 1;

int link(int o, int h) {
	oo[_] = o, oh[_] = h;
	return _++;
}

int oo_[1 + M_ * 2], oh_[1 + M_ * 2], __;

int link_(int o, int h) {
	oo_[__] = o, oh_[__] = h;
	return __++;
}

int ae[N], af[N], ae_[N_], dd[N_], n_;
int ii[M], jj[M], ww[M]; char tt[M]; int ij[M_], cc[M_ * 2], m_;
int pq[1 + N], iq[N], cnt;

int less(int u, int v) { return dd[u] < dd[v]; }

int i2(int i) {
	return (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;
}

void pq_up(int u) {
	int i, j, v;

	for (i = iq[u]; (j = i / 2) && less(u, v = pq[j]); i = j)
		pq[iq[v] = i] = v;
	pq[iq[u] = i] = u;
}

void pq_dn(int u) {
	int i, j, v;

	for (i = iq[u]; (j = i2(i)) && less(v = pq[j], u); i = j)
		pq[iq[v] = i] = v;
	pq[iq[u] = i] = u;
}

void pq_add_last(int u) {
	pq[iq[u] = ++cnt] = u;
}

int pq_remove_first() {
	int u = pq[1], v = pq[cnt--];

	if (v != u)
		iq[v] = 1, pq_dn(v);
	iq[u] = 0;
	return u;
}

void dijkstra(int n, int s) {
	memset(dd, 0x3f, n * sizeof *dd);
	dd[s] = 0, pq_add_last(s);
	while (cnt) {
		int i = pq_remove_first(), o;

		for (o = ae[i]; o; o = oo[o]) {
			int h = oh[o];

			if (!tt[h]) {
				int j = jj[h], d = dd[i] + ww[h];

				if (dd[j] > d) {
					if (dd[j] == INF)
						pq_add_last(j);
					dd[j] = d, pq_up(j);
				}
			}
		}
	}
}

void link2(int i, int j, int c) {
	int h = m_++;

	ij[h] = i ^ j, cc[h << 1] = c, cc[h << 1 | 1] = 0;
	ae_[i] = link_(ae_[i], h << 1);
	ae_[j] = link_(ae_[j], h << 1 | 1);
}

int bfs(int s, int t) {
	static int qu[N_];
	int i, head, cnt;

	for (i = 0; i < n_; i++)
		dd[i] = n_;
	head = cnt = 0;
	dd[s] = 0, qu[head + cnt++] = s;
	while (cnt) {
		int d, o;

		i = qu[cnt--, head++], d = dd[i] + 1;
		for (o = ae_[i]; o; o = oo_[o]) {
			int h_ = oh_[o];

			if (cc[h_]) {
				int h = h_ >> 1, j = i ^ ij[h];

				if (dd[j] > d) {
					dd[j] = d;
					if (j == t)
						return 1;
					qu[head + cnt++] = j;
				}
			}
		}
	}
	return 0;
}

int dfs(int i, int t) {
	int d, o;

	if (i == t)
		return 1;
	d = dd[i] + 1;
	for (o = ae_[i]; o; o = oo_[o]) {
		int h_ = oh_[o];

		if (cc[h_]) {
			int h = h_ >> 1, j = i ^ ij[h];

			if (dd[j] == d && dfs(j, t)) {
				cc[h_]--, cc[h_ ^ 1]++;
				return 1;
			}
		}
	}
	dd[i] = n_;
	return 0;
}

void dinic(int s, int t) {
	while (bfs(s, t))
		while (dfs(s, t))
			;
}

char reachable[N];

void dfs_(int j) {
	int o;

	if (reachable[j])
		return;
	reachable[j] = 1;
	for (o = af[j]; o; o = oo[o]) {
		int h = oh[o], i = ii[h];

		dfs_(i);
	}
}

int main() {
	static double ans[X + 1];
	static int dd1[N], dd2[N], xx[M];
	int n, m, q, h, x, s, t;

	scanf("%d%d", &n, &m);
	for (h = 0; h < m; h++) {
		int i, j, w;

		scanf("%d%d%d", &i, &j, &w), i--, j--;
		ii[h] = i, jj[h] = j, ww[h] = w;
		ae[i] = link(ae[i], h);
	}
	n_ = n + 2, s = n, t = n + 1;
	x = 0;
	while (x < X) {
		int k, y, z, d, d_;

		memset(tt, 0, m * sizeof *tt);
		dijkstra(n, 0);
		memcpy(dd1, dd, n * sizeof *dd);
		d = dd1[n - 1];
		memset(ae_, 0, n_ * sizeof *ae_), __ = 1, m_ = 0;
		link2(s, 0, INF);
		link2(n - 1, t, INF);
		for (h = 0; h < m; h++) {
			int i = ii[h], j = jj[h], w = ww[h];

			if (dd1[i] + w == dd1[j]) {
				tt[h] = 1;
				link2(s, j, 1), link2(i, t, 1);
				if (xx[h] == 0)
					link2(j, i, 1);
			}
		}
		dinic(s, t);
		d_ = INF;
		k = 0;
		memset(af, 0, n * sizeof *af), _ = 1 + m;
		for (h = 0; h < m; h++) {
			int i = ii[h], j = jj[h];

			if (tt[h]) {
				if ((dd[i] == n_) == (dd[j] == n_)) {
					tt[h] = 0;
					af[j] = link(af[j], h);
				} else if (dd[i] != n_) {
					tt[h] = 1;
					k++;
				} else {
					if (xx[h] > 0) {
						tt[h] = 2;
						k--;
						d_ = min(d_, d + xx[h]);
					} else
						tt[h] = 0;
				}
			}
		}
		memset(reachable, 0, n * sizeof *reachable);
		dfs_(n - 1);
		dijkstra(n, 0);
		memcpy(dd2, dd, n * sizeof *dd);
		d_ = min(d_, dd2[n - 1]);
		for (h = 0; h < m; h++)
			if (tt[h] == 2 && dd2[ii[h]] != INF && dd1[jj[h]] != INF && reachable[jj[h]])
				d_ = min(d_, d + dd2[ii[h]] + ww[h] - dd1[jj[h]]);
		y = d_ - d <= (X - x) / k ? x + (d_ - d) * k : X;
		for (z = x; z <= y; z++)
			ans[z] = d + (double) (z - x) / k;
		if (y < X) {
			for (h = 0; h < m; h++)
				if (tt[h] == 1)
					ww[h] += d_ - d, xx[h] += d_ - d;
				else if (tt[h] == 2)
					ww[h] -= d_ - d, xx[h] -= d_ - d;
		}
		x = y;
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &x);
		printf("%f\n", ans[x]);
	}
	return 0;
}


#include <stdio.h>
int main()
{
	int day,exam,give,check,prepare;
	int flag,t;
	int ok;
	int dd[100];
	int num1[101],num2[101],num3[101],num4[101]; //本程序数组全部从零开始
	int i,j;
	while(scanf("%d %d",&day,&exam)!=EOF)
	{
		ok=0;
//		printf("%d %d\n",day,exam);
		flag=0;
		/*基础想法，建立一个一维数组去把天数都赋值为零
		将考试的天数赋值为check+1；
		再建四个数组去保存序号，和字面上的三列数据；
		按照第二组从大到小排序
		重右向做找非零数 并将其赋值为第一列序号值；检查是否大于等于第一列序号值 和是否可以赋值；*/
		for(i=0;i<exam;i++)
		{
			num1[i]=i+1;
			scanf("%d %d %d",&num2[i],&num3[i],&num4[i]);
		}//数组遍历输入
//		for(i=0;i<exam;i++)
//		{
//			printf("%d %d %d %d\n",num1[i],num2[i],num3[i],num4[i]);
//		}//数组测试
		 for(i=0;i<exam-1;i++)
		 {
		 	for(j=0;j<exam-1;j++)
		 	{
		 		if(num2[j]<num2[j+1])
		 		{
		 			t=num2[j];
		 			num2[j]=num2[j+1];
		 			num2[j+1]=t;
		 			t=num3[j];
		 			num3[j]=num3[j+1];
		 			num3[j+1]=t;
		 			t=num4[j];
		 			num4[j]=num4[j+1];
		 			num4[j+1]=t;
		 			t=num1[j];
		 			num1[j]=num1[j+1];
		 			num1[j+1]=t;
				 }
			 }
		 }
//				 printf("序号 发布 考试 复习\n");
//				 		 for(i=0;i<exam;i++)
//				{
//					printf("%d %d %d %d\n",num1[i],num2[i],num3[i],num4[i]);
//				}//数组测试
//			数组排序完成
		 for(i=0;i<100;i++)
		 {
		 	dd[i]=0;
		 }
		 for(i=0;i<exam;i++)
		 {
		 	dd[num3[i]-1]=exam+1;
		 }//将要打印出的考赋值为考试总数+1

//			 for(i=0;i<day;i++)
//			 {
//			 	printf("%d",dd[i]);
//			 }//测试数组赋值是否成功，测试完成

		for(i=0;i<exam;i++)
		{
			for(j=num3[i]-2;j>=0;j--)
			{
				while(num4[i]>0&&j>=0)
				{
					if(dd[j]==0&&j>num2[i]-2)
					{
						dd[j]=num1[i];
						num4[i]--;
					}
					j--;
				}
				if(num4[i]>0)
				flag=1;
				else
				break;
			}
		}
		if(flag==0)
		{

			for(i=0;i<day;i++)
			 {
			 	if(ok!=0)
					printf(" ");
			 	printf("%d",dd[i]);
			 	ok++;
			 }
			 printf("\n");
		}
		 else
		 printf("-1\n");

	}
}


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

int GetSum(int n)
{
    return n + n * (n - 1) / 2;
}

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    int len = abs(a - b);
    printf("%d\n", GetSum(len / 2) + GetSum(len - len / 2));
    return 0;
}


#include<stdio.h>
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
int main()
{
    int a,ta,b,tb,h,m,num=0,t1,t2,i,j,x,y;
    scanf("%d %d",&a,&ta);
    scanf("%d %d",&b,&tb);
    scanf("%d:%d",&h,&m);
    t1=h*60+m;
    t2=t1+ta;
    for(i=5*60;i<24*60;i+=b){
        j=i+tb;
        int x = max(t1, i), y = min(t2, j);
		if (x < y)
			num++;
    }
    printf("%d\n",num);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int i,j=0;
    char w1[50];
    char w2[50];
    char ansr[50];
    char ansl[50];
    int cr=0,cl=0,s;
    int count=0;
    gets(w1);
    gets(w2);
    s=strlen(w2);
    for(i=0;w1[i]!='|';i++)
    {
        cr++;
    }
    for(i=cr+1;i<strlen(w1);i++)
    {
        cl++;
    }
    if(s<abs(cr-cl))
    {
        printf("Impossible");
        return 0;
    }
    else if(((cr+cl+s)%2)!=0)
    {
        printf("Impossible");
        return 0;
    }
    else
    {
        for(i=0;i<cr;i++)
        {
            ansr[i]=w1[i];
            j++;
        }
        j++;
        for(i=cr;i<(cr+cl+s)/2;i++)
        {
            ansr[i]=w2[count];
            count++;
        }
        for(i=0;i<cl;i++)
        {
            ansl[i]=w1[j];
            j++;
        }
        for(i=cl;i<(cr+cl+s)/2;i++)
        {
            ansl[i]=w2[count];
            count++;
        }
    }
    for(i=0;i<(cr+cl+s)/2;i++)
    {
        printf("%c",ansr[i]);
    }
    printf("|");
    for(i=0;i<(cr+cl+s)/2;i++)
    {
        printf("%c",ansl[i]);
    }
    return 0;
}


#include<stdio.h>
int main()
{
long long int c,marks,temp,a=1;
scanf("%lld",&marks);
temp=marks;
while(temp!=0)
{
   if(temp%a!=0)
   {
      break;
   }
   else
   a*=3;
}
c=temp/a+1;
printf("%lld",c);
}


#include<stdio.h>

int main()
{
	int a,b,c,d,e,i,x;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
    for(i=0;;i++){
    	if(i==0){
    		x=b;
    	}
    	else{
    		x=b+i*d;
    	}
    	if(x>c){
    		x=c;
    	}
    	if(i==0){
    		a=a-x;
    	}
    	else{
    		a=a-x+e;
    	}
    	if(a<=0){
    		break;
    	}
    }
	printf("%d",i+1);
	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    double r,x2,y2,x1,y1,d;
    double s;
    scanf("%lf%lf%lf%lf%lf",&r,&x1,&y1,&x2,&y2);
    d = sqrt((y2 - y1)*(y2 - y1) + (x2 - x1)*(x2 - x1));

    s=d/r/2;

    printf("%.0lf\n",ceil(s));

    return 0;
}


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


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

    }
}


#include<stdio.h>
long long int ans,t,a,b,c,p,q,r;
int main()
{
    scanf("%I64d %I64d %I64d",&a,&b,&c);
    if(a==b&&a==c)
    {
        printf("%I64d",a);
        return 0;
    }
    if(a>=b&&a>=c)
    {
        p=a;
        if(b>c)
        {
            q=b;r=c;
        }
        else
        {
            q=c;r=b;
        }
    }
    else if(b>=a&&b>=c)
    {
        p=b;
        if(a>c)
        {
            q=a;r=c;
        }
        else
        {
            q=c;r=a;
        }
    }
    else
    {
        p=c;
        if(a>b)
        {
            q=a;r=b;
        }
        else
        {
            q=b;r=a;
        }
    }

    t=(p-q)/2;
    if(r>=t)
    {
        r=r-t;
        p=p-(t*2);
        ans=ans+t;
    }
    else
    {
        p=p-(r*2);
        ans=ans+r;r=0;
    }
    p=p-r;
    q=q-r;
    ans=ans+r;
    t=q*2;
    if(p>=t)
    {
        ans=ans+q;
    }
    else
    {
        r=(p+q)/3;
        ans=ans+r;
    }
    printf("%I64d",ans);
    return 0;
}


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

int main()
{
	long long int t,n,l,k,d[200],a[200],flag,i,tmr,temp;
	scanf("%lld",&t);
	while(t--)
	{
		scanf("%lld %lld %lld",&n,&k,&l);
		for(i=0;i<n;i++)
		{
			scanf("%lld",&d[i]);
		}
		flag=0,tmr=1000;
		for(i=0;i<n;i++)
		{
			if(d[i]+k<=l)
			{
				a[i]=d[i];
				tmr=1000;
			}
			else if(d[i]>l)
			{
				flag=1;
				// printf("%d-%d\n",d[i],i);
				break;
			}
			else if(d[i]+k>l)
			{
				if(i==0 || tmr==1000)
				{
					a[i]=l;
					tmr=l-d[i];
				}
				else
				{
					if(tmr>0)
					{
						temp=a[i-1]-d[i-1];
						a[i]=d[i]+tmr-1;
						tmr--;
						if(a[i]>l)
						{
							tmr=tmr-(a[i]-l);
							a[i]=l;
						}
					}
					else
					{
						tmr=tmr-1;
						if(d[i]-tmr>l)
						{
							flag=1;
							// printf("%d\n",i);
							break;
						}
						else
						{
							a[i]=d[i]-tmr;
						}
						// if(tmr==-k)
						// {
						// 	tmr=k;
						// }
					}
				}
			}
		}
		if(flag==1)
		{
			printf("No\n");
		}
		else
		{
			printf("Yes\n");
		}
	}
}


#include<stdio.h>
int main()
{
    char st[1000];
    scanf("%s",st);
    if(st[0]>='a' && st[0]<='z')
    st[0]=st[0]-32;
    printf("%s\n",st);
    return 0;
    }


#pragma comment(linker, "/STACK:1024000000,1024000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC optimize("inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <stdio.h>

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

int n, m, best;
long long g[45], rest[45];
long long whole;

void dfs(long long mask, int cur, int cura) {
	if (cura >= best) return;
	if (cur >= n * m) return;
	if (mask == whole) best = cura;
	else if ((mask | rest[cur]) ^ whole) return;
	else dfs(mask | g[cur], cur + 1, cura + 1),
	dfs(mask, cur + 1, cura);
}

int main() {
	register int i, j, k, x, y;
	scanf("%d%d", &n, &m);
	whole = (1LL << n * m) - 1;
	for (i = 0; i < n; ++ i)
		for (j = 0; j < m; ++ j)
			for (k = 0; k < 5; ++ k) {
				x = i + dx[k], y = j + dy[k];
				if (x < 0 || x >= n || y < 0 || y >= m) continue;
				g[i * m + j] |= 1LL << x * m + y;
			}
	for (i = n * m - 1; i >= 0; -- i) rest[i] = rest[i + 1] | g[i];
	best = n * m; dfs(0, 0, 0);
	printf("%d\n", n * m - best);
	return 0;
}


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

int main()
{
    int n,m,r,s1[35],s2[35];
    int min_s=1001, max_b=0;
    scanf("%d %d %d",&n,&m,&r);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&s1[i]);
        min_s = min_s > s1[i] ? s1[i] : min_s;
    }
    for(int i=0;i<m;i++)
    {
        scanf("%d",&s2[i]);
        max_b = max_b < s2[i] ? s2[i] : max_b;
    }
    if(min_s>=max_b)
        printf("%d",r);
    else
        printf("%d",r+(r/min_s)*(max_b-min_s));
}


#include <stdio.h>

int main(void) {
	// count the number of 1..9
	// check if cucumber can press
	char a[4][4];
	int k;
	int panel[9]= {0};
	int temp;
	scanf("%d\n", &k);
	for (int i = 0; i<4; i++)
	{
		for (int j= 0; j < 4; j++)
		{
			scanf(" %c", &a[i][j]);
			if (a[i][j] != '.')
			{
				temp = a[i][j] - '0';
				panel[temp -1]++;
			}
		}
	}
	for (int i = 0; i < 9; i++)
	{
		if (panel[i] > k*2)
		{
			printf("NO");
			return 0;
		}
	}
	printf("YES");
}


#include <stdio.h>

#define N	100

int main() {
	static int aa[N];
	int n, i, cnt;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	for (i = 1; i < n; i++)
		if (aa[i - 1] != 1 && aa[i] != 1) {
			printf("Infinite\n");
			return 0;
		}
	printf("Finite\n");
	cnt = 0;
	for (i = 1; i < n; i++)
		cnt += aa[i] == 1 ? aa[i - 1] + 1 : i >= 2 && aa[i] == 2 && aa[i - 2] == 3 ? 2 : aa[i] + 1;
	printf("%d\n", cnt);
	return 0;
}


#include <stdio.h>
void news(int *a,int start,int num,int sum,int newsum,int *flag)
{
    int i;
    if (num==3){
        if (newsum==sum-newsum){
            *flag=1;
            return;
        }
    }
    for (i=start;i<6;++i) news(a,i+1,num+1,sum,newsum+a[i],flag);
}
int main(void)
{
    int a[6],i,sum,flag=0;
    for (i=0;i<6;++i) {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    news(a,0,0,sum,0,&flag);
    if (flag==1) printf("YES");
    else printf("NO");
    return 0;
}


/*
Author:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%   LALIT KUNDU      %%%%%%%%
%%%%%%%%   IIIT HYDERABAD   %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<malloc.h>
#define min(a,b)(a>b?b:a)
#define max(a,b)(a<b?b:a)
#define sort(arr,n) qsort(arr,n,sizeof(arr[0]),compare)
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define su(n) scanf("%llu",&n)
#define rep(i,start,end) for(i=start; i<end; i++)
#define pdn(n) printf("%d\n",n)
#define pln(n) printf("%lld\n",n)
#define pun(n) printf("%llu\n",n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define pu(n) printf("%llu",n)
#define pn printf("\n")
#define ps printf(" ")
#define llu long long int
#define MOD 1000000007
llu mpow(llu a, llu n)
{
    llu ret=1;
    llu b=a;
    while(n)
    {
        if(n&1) ret=(ret*b)%MOD;
        b=(b*b)%MOD;
        n>>=1;
    }
    return (llu)ret;
}
int main()
{
    int i;
    char str[109];
    scanf("%s",str);
    int len=strlen(str);
    llu p=mpow(2,len-1),count=1,ans=0;
    for(i=len-1; i>=0; i--)
    {
        ans=(ans+(p*(str[i]-'0')*count))%MOD;
        count=(count*2)%MOD;
    }
    printf("%lld\n",ans);
    return 0;
}


#include<stdio.h>
#define MOD 1000000007

long long mpow(long long a, long long p)
{
  a %= MOD;

  long long r = 1;
  while (p) {
    if ((1 & p)) r = (r * a) % MOD;
    a = (a * a) % MOD;
    p >>= 1;
  }
  return r;
}

int inv(long long x)
{ return mpow(x, MOD-2); }

#define MAXF 100005

long long factorial[MAXF];

long long possib(long long width, long long boxes, long long minh)
{
  long long separators = width-1;
  long long elements = boxes-width*minh;

  if(elements < 0) return 0;
  else return (factorial[separators+elements]*inv(factorial[separators]*factorial[elements])) % MOD;
}

long long all_possib, nice_possib;
void add_all(long long x)
{
  x %= MOD;
  all_possib += x;
  all_possib %= MOD;
}
void add_nice(long long x)
{
  x %= MOD;
  nice_possib += x;
  nice_possib %= MOD;
}

int main()
{
  long long fac;
  int i;
  int result;

  i = 0;
  for(fac = 1; i<MAXF; fac = fac*i % MOD){
    factorial[i] = fac;
    i++;
  }

  int F, W, H, width;
  scanf("%d %d %d\n", &F, &W, &H);

  if(W == 0 || F == 0){
    if(W == 0 || W > H) printf("1\n");
    else printf("0\n");
    return 0;
  }

  all_possib = 0;
  nice_possib = 0;
  for(width=1; width<=W; width++){
    add_all(possib(width, F, 1)*possib(width, W, 1));
    add_all(possib(width+1, F, 1)*possib(width, W, 1));
    add_all(possib(width, W, 1)*possib(width, F, 1));
    add_all(possib(width+1, W, 1)*possib(width, F, 1));

    add_nice(possib(width, F, 1)*possib(width, W, H+1));
    add_nice(possib(width+1, F, 1)*possib(width, W, H+1));
    add_nice(possib(width, W, H+1)*possib(width, F, 1));
    add_nice(possib(width+1, W, H+1)*possib(width, F, 1));
  }
  result = nice_possib*inv(all_possib) % MOD;

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

  return 0;
}


//bainchod
//bainchod
//bainchod
//bainchod
//bainchod
//bainchod
//bainchod

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

    printf("%d",(n/2)+n);

}


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

int main(){
    double n,R,r;
    double pi = 3.141592653589793;
    double ht;
	int flag = 0;
    scanf("%lf%lf%lf",&n,&R,&r);

	if(r<=R){
		if(n==1){
			if(r<=R) flag = 1;
		}else if(n==2){
			if(2*r<=R) flag = 1;
		}else{
			ht = asin(r/(R-r));
			if(n*ht - 1e-7 <= pi) flag = 1;
		}
	}
    if(flag){
    	printf("YES");
    }else{
    	printf("NO");
    }

	return 0;
}


#include <stdio.h>
int b[9];
void printDivisors(int n)
{
    for (int i=n;i>=1;i--)
    {
    	  if (n%i==0)
            {
          		for (int j = 0; j< 9; ++j)
          		{
          			//printf("%d\n",b[j]);
          			if (b[j]==i)
          			{
          				printf("%d\n",i );
          				return ;
          			}
          		}
            }
    }
}
void function()
{
	for (int i = 1;  ((1<<i)-1)*(1<<(i-1))<=100000; ++i)
	{
		b[i]=((1<<i)-1)*(1<<(i-1));
		//printf("%d\n",b[i] );

	}
}
/* Driver program to test above function */
int main()
{
    int n;
    scanf("%d",&n);
    //printDivisors(n);
    function();
   // printf("%d\n",((1<<2)-1)*(1<<(2-1)) );
    printDivisors(n);
    return 0;
}


#include <stdio.h>
int main(void)
{
    int i,j,b,k,l,n,max=0,a=0,count1=0,count2=0;
    int bin[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&bin[i]);
        if(bin[i]==1){
            count1++;
        }
    }
    for(i=0;i<n;i++){
        a=0;
        count2=0;
        for(l=0;l<i;l++){
            if(bin[l]==1){
                a++;
                count2++;
            }
        }
        for(j=i;j<n;j++){
            if(bin[j]==1){
                count2++;
            }
            if((1-bin[j])==1){
                a++;
            }
             if((a+(count1-count2))>max){
                max=a+(count1-count2);
            }
        }
    }
    printf("%d",max);
    return 0;
}


#include <stdio.h>

int main()
{

	int n, k, i, solution = 0;
	int groups[100][2] = {{0}};

	scanf("%i %i", &n, &k);
	for (i = 0; i < n; ++i)
	{

		int a;

		scanf("%i", &a);
		++groups[i % k][a - 1];

	}

	for (i = 0; i < k; ++i)
	{
		solution += ((groups[i][0] < groups[i][1]) ? groups[i][0] : groups[i][1]);
	}

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

	return 0;

}


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

int min(int a, int b) {return a<b?a:b;}
char a[200];
int na[10],nb[10];

int main()
{
    int i;
	scanf("%s",a);
    for(i=0;i<strlen(a);i++)
        {
		 int p=a[i]-'0';
         if(p==9) p=6;
         if(p==5) p=2;
         na[p]++;
        }
    scanf("%s",a);
    for(i=0;i<strlen(a);i++)
       {
         int q=a[i]-'0';
         if(q==9) q=6;
         if(q==5) q=2;
         nb[q]++;
       }
    int n=201;
    for(i=0;i<10;i++)
      if(na[i]!=0)
        n=min(n,nb[i]/na[i]);
   printf("%d",n);
   return 0;
}


#include<stdio.h>
int main()
{
    char str[100],t;
    int n;
    int i,j;
    int count=1;
    scanf("%d",&n);
    getchar();
    scanf("%s",str);
    getchar();
    if (n<26)
    {
        printf("NO");
        return 0;
    }
    for (i=0;i<n;i++)
    {
        if (str[i]<=90)
        {
            str[i]+=32;
        }
    }
    for (i=1;i<n;i++)
    {
        for (j=0;j<i;j++)
            if (str[i]==str[j])
                goto s;
        count++;
        s:;
    }
    if (count==26) printf("YES");
    else printf("NO");
    return 0;
}


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


#include <stdio.h>

int a[7];

int main(){
	int t;
	scanf("%d", &t);
	for (int i = 1; i <= t; i++){
		int x;
		scanf("%d", &x);
		for (int j = 1; j <= 3; j++){
			scanf("%d", &a[j]);
		}
		if (a[x] == 0){
			printf("NO\n");
		} else {
			int t = x;
			x = a[x];
			a[t] = 0;
			if (a[x] == 0){
				printf("NO\n");
			} else {
				printf("YES\n");
			}
		}
	}
	return 0;
}


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

int main()
{
    int n, a, b, cnt=0, x, c;

    scanf("%d",&n);

    for(a=1;a<=n;a++)
    {
        for(b=a;b<=n;b++)
        {
            c=a*a+b*b;
            if(c>n*n)
                continue;
            x=(int)sqrt(c*1.0);
            if(x*x==c)
                cnt++;
        }
    }
    printf("%d\n",cnt);

    return 0;
}


#include <stdio.h>
main(){
    long long int a,b,x,y,temp;
 scanf("%I64d %I64d %I64d %I64d",&a,&b,&x,&y);
 long long int t1=x,t2=y;
 while(t2!=0){
     temp=t2;
     t2=t1%t2;
     t1=temp;
 }
    x=x/t1;
    y=y/t1;
    if(a/x<b/y) printf("%I64d",a/x);
    else printf("%I64d",b/y);

}


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

int main()
{
    char table[8][8];
    int i , j ;
    int counter = 0 ;
    int total = 0 ;

    for ( i=0 ; i<8 ; ++i ){
        scanf("%s" , table[i]);
    }

    for ( i=0 ; i<8 ; ++i ){
        counter = 0;
        for ( j=0 ; j<8 ; ++j ){
            if ( table[i][j] == 'B' ){
                ++counter ;
            }
        }
        if ( counter == 8 ){
            ++total ;
        }
    }

    if ( total == 8 ){
        printf("8");
        return 0 ;
    }

    for ( j=0 ; j<8 ; ++j ){
        counter = 0;
        for ( i=0 ; i<8 ; ++i ){
            if ( table[i][j] == 'B' ){
                ++counter ;
            }
        }
        if ( counter == 8 ){
            ++total ;
        }
    }

    printf("%d",total);

    return 0;
}


/*
 * main.c
 *
 *  Created on: 30 ���� 2014 �.
 *      Author: ulgish
 */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

typedef unsigned long long uint64;
typedef long long int64;
typedef char byte;

void int64_print(int64 n){
	int64 carry = 10;
	char buf[20];
	buf[0] = '\0';
	int i = 0, j;
	while (n > 0){
		buf[i] = n % carry;
		n = n / carry;
		i += 1;
	}
	i--;
	for (j = i; j>= 0; j--){
		printf("%c", 48 + buf[j]);
	}
}
void uint64_print(uint64 n){
	uint64 carry = 10;
	char buf[20];
	buf[0] = '\0';
	int i = 0, j;
	while (n > 0){
		buf[i] = n % carry;
		n = n / carry;
		i += 1;
	}
	i--;
	for (j = i; j>= 0; j--){
		printf("%c", 48 + buf[j]);
	}
}

uint64 uint64_read(){
	char* s = (char*) calloc(20, sizeof(char));
	s[0] = '\0';
	scanf("%s", s);
	//printf("=======%s\n", s);
	uint64 ret = 0;
	uint64 carry = 1;
	int len = strlen(s), i;
	for (i = 0; i < len; i++){
		ret += carry * (s[len-1-i] - 48);
		carry*=10;
	};
	free(s);
	return ret;
}

int64 int64_read(){
	char* s = (char*) calloc(21, sizeof(char));
	s[0] = '\0';
	scanf("%s", s);
	//printf("=======%s\n", s);
	int64 ret = 0;
	int64 carry = 1;
	int len = strlen(s), i;
	for (i = 0; i < len; i++){
		ret += carry * (s[len-1-i] - 48);
		carry*=10;
	};
	free(s);
	return ret;
}

typedef struct{
	byte index[26];
}set;

typedef set* setp;

setp set_create(){
	setp ret = (setp) malloc(sizeof(set));
	memset(ret->index, 0x0, sizeof(byte)*26);
	return ret;
}

int set_count(setp s,char c){
	byte i = (byte) (c - 'a');
	return s->index[i];
}

setp set_add(setp s, char c){
	byte i = (byte) (c - 'a');
	s->index[i]++;
	return s;
}

int set_in(setp part, setp global){
	int i;
	for (i = 0; i < 26; i++){
		if (part->index[i] > global->index[i]){
			return 0;
		}
	}
	return 1;
}

int set_not_equal(setp set1, setp set2){
	return (memcmp(set1->index, set2->index, sizeof(byte)*26));
}

setp set_free(setp s){
	free(s);
	s = NULL;
	return s;
}

setp set_from_str(const char* s){
	int len = strlen(s);
	setp ret = set_create();
	int i;
	for (i = 0; i < len; i++){
		ret = set_add(ret, s[i]);
	}
	return ret;
}

int main(){
	char s[102], t[102];
	scanf("%s %s", s, t);
	//printf("%s\t %s", s, t);
	setp set_s = set_from_str(s);
	setp set_t = set_from_str(t);
	int len_s = strlen(s);
	int len_t = strlen(t);
	if (!set_in(set_t, set_s)){
		printf("need tree\n");
		return 0;
	}

	if ((len_t == len_s) && (!set_not_equal(set_s, set_t))){
		printf("array\n");
		set_s = set_free(set_s);
		set_t = set_free(set_t);
		return 0;
	}
	set_s = set_free(set_s);
	set_t = set_free(set_t);
	int i_s = 0, i_t = 0;
	while ((i_s < len_s) && (i_t < len_t)){
		if (t[i_t] == s[i_s]){
			i_t++;
		}
		i_s++;
	}
	if ((i_t == len_t) && (i_s <= len_s)){
		printf("automaton\n");
		return 0;
	}else{
		printf("both\n");
		return 0;
	}
	return 0;
}


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

int main(void)
{
    int i, n, s, pos_c, pos_s, vel_c, win;
    char states[201], direction[10];

    memset(states, 0, sizeof(states));
    memset(direction, 0, sizeof(direction));

    scanf("%d%d%d%*s%s%s", &n, &pos_s, &pos_c, direction, states);

    if (!strcmp(direction, "head")) vel_c = -1;
    else vel_c = 1;

    s = strlen(states);

    if (pos_s < pos_c) pos_s = 1;
    else pos_s = n;

    win = 0;

    for (i = 0; i < s; i++)
    {
        if (pos_c == pos_s) { win = 1; break; }
        if (pos_c == 1 && vel_c == -1) vel_c = 1;
        if (pos_c == n && vel_c == 1) vel_c = -1;

        if (states[i] == '0')
        {
            pos_c += vel_c;
        }
        else
        {
            pos_c += vel_c;
            if (pos_c > 1) {
                if (vel_c == 1) pos_s = 1;
                else pos_s = n;
            }
            if (pos_c < n) {
                if (vel_c == -1) pos_s = n;
                else pos_s = 1;
            }
        }
    }

    if (win)
        printf("Controller %d\n", i);
    else
        printf("Stowaway\n");

    return 0;
}


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

int main(){
    int n,*arr,i,alice,maj=0,total,max,*result = malloc(100*sizeof(int));
    scanf("%d",&n);
    arr = (int*)malloc(n*sizeof(int));
    for(i=0;i<n;i++){
        scanf("%d",&arr[i]);
        maj = maj + arr[i];
    }
    maj = maj/2;
    alice = arr[0];
    if(alice>maj){
        printf("%d\n%d",1,1);
        return 0;
    }
    total = alice;
    max = -1;
    int k =1;
    result[0]=1;
    for(i=1;i<n;i++){
     if(arr[i]<=alice/2){

        result[k]=i+1;
         k++;
         total = total + arr[i];
     }
    }
    if(total>maj){
        printf("%d\n",k);
        for(i=0;i<k;i++){
            printf("%d ",result[i]);
        }
    }
    else{
        printf("%d",0);
    }

 return 0;
}


#include <stdio.h>
#include <math.h>
#include <conio.h>
int all_p_factor(int* ara,int* power,int number){
    int factor=2,i=0,p;
    if(number==1){
        ara[0]=1;power[0]=1;
        return 1;
    }
    while(number!=1){
        if((number%factor)==0){
            ara[i]=factor;
            p=0;
            while((number%factor)==0){
                number=number/factor;
                p++;
            }
            power[i]=p;
            i++;
        }
        factor++;
    }
    return i;
}
int max_(int* data,int sz){
    int i,mx=0;
    for(i=0;i<sz;i++){
        if(mx<data[i])mx=data[i];
    }
    return mx;
}
int _chk(int* data,int j){
    int i;
    for(i=0;i<j;i++){
        if(data[i]!=data[0])return 0;
    }
    return 1;
}
int main(){
    int i,prime[22],power[22],num,min_num=1,op=0,j;
    double mx,lg,cl;
    scanf("%d",&num);
    j=all_p_factor(prime,power,num);
        mx=max_(power,j);
        lg=log2(mx);
        if(lg==ceil(lg)){
            if(_chk(power,j)==0){
                op=((int)ceil(lg))+1;
            }
            else{
                op=(int)ceil(lg);
            }
        }
        else{
            op=((int)ceil(lg))+1;
        }

    for(i=0;i<j;i++)min_num*=prime[i];
    printf("%d %d ",min_num,op);
    return 0;
}


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

#define FOR(i, a, b) for (i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int cmpfunc (const void * a, const void * b){
	//qsort(values, 5, sizeof(int), cmpfunc);
	return ( *(int*)a - *(int*)b );
}

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;
}
// long long ncr(int n, int k)
// {
//     long long C[k+1];
//     memset(C, 0, sizeof(C));
//   	int i;
//   	int j;
//     C[0] = 1;  // nC0 is 1

//     for (i = 1; i <= n; i++)
//     {
//         // Compute next row of pascal triangle using
//         // the previous row
//         for ( j = min(i, k); j > 0; j--)
//             C[j] = C[j] + C[j-1];
//     }
//     return C[k];
// }

void solve(int t){
	int n,k;
	scanf("%d%d",&n,&k);
	int a[n];
	int i,j;
	for(i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}

	// printf("Case #%d: %ld\n",t,count);
}

long long gcd(long long a , long long b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}

int main(){
	int n,k,a,b;
	scanf("%d%d",&n,&k);
	scanf("%d%d",&a,&b);
	int i,j;
	long long maximum = LLONG_MIN, minimum = LLONG_MAX;
	long long l = a-b;
	long long total = (long long)n*k;
	while(l <= total){
		if(l <= 0){
			l += k;
			continue;
		}
		long long g = ((long long)n*k)/gcd((long long)n*k,(long long)l);

		maximum = max(g,maximum);
		minimum = min(g,minimum);
		l += k;
	}

	l = a+b;
	while(l <= total){
		if(l <= 0){
			l += k;
			continue;
		}
		long long g = ((long long)n*k)/gcd((long long)n*k,(long long)l);

		maximum = max(g,maximum);
		minimum = min(g,minimum);
		l += k;
	}

	l = k-a+b;
	while(l <= total){
		if(l <= 0){
			l += k;
			continue;
		}
		long long g = ((long long)n*k)/gcd((long long)n*k,(long long)l);

		maximum = max(g,maximum);
		minimum = min(g,minimum);
		l += k;
	}

	l = k-a-b;
	while(l <= total){
		if(l <= 0){
			l += k;
			continue;
		}
		long long g = ((long long)n*k)/gcd((long long)n*k,(long long)l);

		maximum = max(g,maximum);
		minimum = min(g,minimum);
		l += k;
	}

	printf("%I64d %I64d\n",minimum,maximum);
}


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

typedef unsigned long long ull;
typedef unsigned char uchar;

#define MAX 222
int g[MAX][MAX];
int gn[MAX];
int n;
int where[MAX];

typedef struct {
    ull key[4];
    int at;
} hashdata_t;

#define MAXHASH 5000007
int maxhash=MAXHASH;

uchar hash[(MAXHASH+7)/8];  /*  bit i set if element i is taken */
hashdata_t hashdata[MAXHASH];

int gethash(hashdata_t *h) {
    int res=h->key[0]%maxhash;
    res=((ull)res*maxhash+h->key[1])%maxhash;
    res=((ull)res*maxhash+h->key[2])%maxhash;
    res=((ull)res*maxhash+h->key[3])%maxhash;
    res=(res*3+h->at)%maxhash;
    return res;
}

#define HASHBIT(pos) (hash[pos>>3]&(1<<(pos&7)))

int gethashpos(hashdata_t *h) {
  int pos=gethash(h),i;
  while(1) {
    if(!HASHBIT(pos)) break;
        for(i=0;i<4;i++) if(hashdata[pos].key[i]!=h->key[i]) goto next;
        if(hashdata[pos].at!=h->at) goto next;
    break;
    next:
    pos++; if(pos==maxhash) pos=0;
  }
  return pos;
}

int exists(hashdata_t *h) {
    int pos=gethashpos(h),i;
    for(i=0;i<4;i++) if(hashdata[pos].key[i]!=h->key[i]) return 0;
    return hashdata[pos].at==h->at;
}

void puthash(hashdata_t *h) {
  int pos=gethashpos(h);
  hash[pos>>3]|=1<<(pos&7);
  hashdata[pos]=*h;
}

void inithashdata() {
  memset(hash,0,sizeof(hash));
}

#define Q 500000
int qs,qe,qe2;
hashdata_t q[Q];

#define SET(var,i) var[(i)>>6]|=1ULL<<((i)&63)
#define CLEAR(var,i) var[(i)>>6]&=~(1ULL<<((i)&63))
#define ISSET(var,i) var[(i)>>6]&(1ULL<<((i)&63))

void insert1(ull mask[4],int at) {
    hashdata_t h;
    int i;
    h.key[0]=mask[0];
    h.key[1]=mask[1];
    h.key[2]=mask[2];
    h.key[3]=mask[3];
    h.at=at;
    if(exists(&h)) return;
    puthash(&h);
    q[qe2].at=at;
    q[qe2].key[0]=mask[0];
    q[qe2].key[1]=mask[1];
    q[qe2].key[2]=mask[2];
    q[qe2].key[3]=mask[3];
    qe2++; if(qe2==Q) qe2=0;
}

void pop(hashdata_t *h) {
    h->key[0]=q[qs].key[0];
    h->key[1]=q[qs].key[1];
    h->key[2]=q[qs].key[2];
    h->key[3]=q[qs].key[3];
    h->at=q[qs].at;
    qs++; if(qs==Q) qs=0;
}

int bfs() {
    int i,j,moves=0,done;
    ull cur[4];
    hashdata_t c;
    qs=qe=qe2=0;
    for(i=0;i<4;i++) cur[i]=0;
    for(i=0;i<n;i++) SET(cur,i);
    insert1(cur,0);
    insert1(cur,1);
    insert1(cur,2);
    qe=qe2;
    while(qs!=qe) {
        while(qs!=qe) {
            pop(&c);
            /* remove all at current computer */
            do {
                done=1;
                for(i=0;i<n;i++) if(where[i]==c.at && ISSET(c.key,i)) {
                    for(j=0;j<gn[i];j++) if(ISSET(c.key,g[i][j])) goto wrong;
                    /* perform game i */
                    CLEAR(c.key,i);
                    done=0;
                wrong:;
                }
            } while(!done);
            if(!c.key[0] && !c.key[1] && !c.key[2] && !c.key[3]) return moves;
            /* move to next computer */
            c.at=(c.at+1)%3;
            insert1(c.key,c.at);
        }
        qe=qe2;
        moves++;
    }
    puts("ERROR");
    return -1;
}

int main() {
    int i,j,k;
    memset(g,0,sizeof(g));
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&where[i]),where[i]--;
    for(i=0;i<n;i++) {
        scanf("%d",&k);
        gn[i]=k;
        for(j=0;j<k;j++) {
            scanf("%d",&g[i][j]);
            g[i][j]--;
        }
    }
    inithashdata();
    printf("%d\n",bfs()+n);
    return 0;
}


#include<stdio.h>
int count=0;
void fun(char a[],int i,int j)

{
	int nl,nr,nu,nd,k;
	nl=nr=nd=nu=0;
	for(k=i;k<=j;k++)
	{
		 if(a[k]=='L')
		 nl++;
		  if(a[k]=='R')
		  nr++;
		if(a[k]=='U')
		   nu++;
		    if(a[k]=='D')
		    nd++;
		 //printf("%c",a[k]);
	}
//	printf("\n");
	if(nl==nr&&nu==nd)
	count++;
}
int main()
{
	int n,i,j;
	char a[1000];
	scanf("%d",&n);
	scanf("%s",&a);
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if((j+i)<n)
			fun(a,j,j+i);
		}
	}
	printf("%d",count);
}


#include <stdio.h>

int main(){

int i, n, m, c = 0, a;
scanf("%d%d", &n, &m);
for(i = 1; i <= n; i++){
    c = c + i;
    if(c == m){
       printf("0\n");
       break;
    }
    else if(i == n && c < m){
       i = 0;
    }
    else if(c > m){
       c = c - i;
       a = m - c;
       printf("%d\n", a);
       break;
    }
}

return 0;
}


#include<stdio.h>
#include<string.h>
int main (){int n,i,l,count=0,m=0;char integer[10],result[10000];scanf("%d",&n);snprintf(integer, 10, "%d", n);l=strlen(integer);int starting=1,we_can_start_now=0,next=0;for(;;){for(i=0;i<l;i++){if(integer[i]>='1' && starting==1)result[m]='1',m++,starting=0,integer[i]=integer[i]-'1'+48;if(we_can_start_now==1){if(integer[i]>='1')result[m]='1',m++,integer[i]=integer[i]-'1'+48;else result[m]='0',m++;}if(starting==0)we_can_start_now=1,next=1;}starting=1;we_can_start_now=0;/*printf(" ");*/if(next==0)break;result[m]=' ',m++;count++;next=0;}printf("%d\n",count);puts(result);return 0;}


#include <stdio.h>

int main(void)
{
    long long int filyaS, filyaE;
    long long int sonyaS, sonyaE;
    long long int k;
    long long int meetingS, meetingE;

    scanf("%lld %lld %lld %lld %lld", &filyaS, &filyaE, &sonyaS, &sonyaE, &k);

    if(filyaS>sonyaS)
    {
        meetingS=filyaS;
    }
    else
    {
        meetingS=sonyaS;
    }

    if(filyaE>sonyaE)
    {
        meetingE=sonyaE;
    }
    else
    {
        meetingE=filyaE;
    }

    if(meetingE-meetingS>=0)
    {
        if(k>=meetingS&&meetingE>=k)
        {
            printf("%lld", meetingE-meetingS);
        }
        else
        {
            printf("%lld", meetingE-meetingS+1);
        }
    }
    else
    {
        printf("0");
    }

    return 0;
}


#include<stdio.h>
int main()
{
    int k, a, b, v;
    int temp;
    int sum = 0;
    scanf("%d%d%d%d", &k, &a, &b, &v);
    temp = a;
    if(a < v)
        sum = 1;
    else
        if(b < k-1)
            {
                temp = a - (b+1) * v;
                sum++;
                if(temp)
                   // sum = 1;
              //  else
                   sum +=((temp-1)/v + 1);
            }
        else
        {
            while(temp > 0 && b >= k-1)
            {
                temp = temp - k * v;
                sum++;
                b = b - k + 1;
            }
            if (b < k-1 && temp > 0)
            {
                temp = temp - (b + 1) * v;
                if(temp <= 0)
                    sum++;
                else
                {
                    if(temp % v)
                        sum += temp / v + 2;
                    else
                        sum += temp / v + 1;
                }
            }

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


#include<stdio.h>

int main()
{
    int n,a[110][110],sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
    for(int j=0;j<n;j++)
    {
    scanf("%d",&a[i][j]);
    sum=sum+a[i][j];
    }
    }
    if(n<=3)
    {
    printf("%d",sum);
    }
    else
    {
  for(int j=1;j<n;j++)
   {
   sum=sum-a[0][j];
    sum=sum-a[n-1][j];
    sum=sum-a[j][0];
    sum=sum-a[j][n-1];
    j++;
   }
    printf("%d",sum);
    }
    return 0;
}


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