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

int main(){

    int n, k, count = 0;
    scanf("%d", &n);
    scanf("%d", &k);
    int i = 0, j = n -1;

    int a[100];

    for(i = 0; i < n; i++)
		scanf("%d", &a[i]);
    i = 0;
    while (i < j) {
      if (a[i] <= k) {++i; ++count;}
      if (a[j] <= k) {--j; ++count;}
      if (a[i] > k & a[j] > k) break;
    }
    if ((i == j) & (a[i] <= k)) ++count;
    printf("%d", count);
    return 0;
}


#include <stdio.h>
int main ()
{
int a1,a2,a3,a4;
scanf ("%d%d%d%d",&a1,&a2,&a3,&a4);

if (a1>0&&a2>0&&a3>0&&a4>0)
{

if (a1+a2 == a3+a4)
{
printf ("YES\n");
}
else if (a2+a3 == a4+a1)
{
printf ("YES\n");
}
else if (a3+a1 == a4+a2)
{
printf ("YES\n");
}
else if (a1 == a2+a3+a4)
{
    printf("YES\n");
}
else if (a2 == a1+a3+a4)
{
    printf("YES\n");
}
else if (a3 == a2+a1+a4)
{
    printf("YES\n");
}
else if (a4 == a2+a3+a1)
{
    printf("YES\n");
}
else
{
printf ("NO\n");
}
}

}


#include<stdio.h>
int main()
{
	int n, k, i;
	scanf("%d %d", &n, &k);
	int arr[n];
	for(i=0;i<n;i++)
	{
		scanf("%d", arr+i);
	}
	int t=100;
	for(i=0;i<n;i++)
	{
		if(k%arr[i]==0)
		{
			if(k/arr[i]<t)
			{
				t=k/arr[i];
			}
		}
	}
	printf("%d\n", t);
}


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


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

	printf("%d\n", a + b == 2 ? 0 : a + b - 2 - !((a - b) % 3));

	return 0;
}


/*
Spirits coming from the mind,
waking up my deepest horrors,
capture my thoughts, make me blind.

Weird, ‘cause I don't want to see
the abyss of my possibilities.

Scared I can't look away.

It has come to my side.
Sister demon - my bride.

I want you, I need you
and I have set you free.
You're always right behind me,
I know the devil's sent you to me.
You want me, you need me,
now that I've set you free.
Look always right behind you,
You know the devil's sent me to you.

What has started as a longing
almost is possession now,
it drives me again and again.
Put a light into your window,
maybe I can find a hold.
I run against myself ‘till I find the end.

Sent by the devil
*/

/* .................... compiled by alankar....................
*/

//......................SHORTCUTS..............................

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

#define pi 3.14159265358979323846  //float type
#define MAX 100000  //for rmq
#define SQRTMAX 317   //for rmq
//#define gc getchar_unlocked

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

//only for +ve and single terms
#define s(x) scanf("%d",&x);
#define sl(x) scanf("%lld",&x);
#define p(x) printf("%d\n",x);
#define pl(x) printf("%lld\n",x);
//..........................................................

typedef long long int ll;
const ll MOD=1000000007;

//returns int and +ve numbers

/*inline int inp(){
    int n=0;
    char c;
    c=gc();
    while(c<'0' || c>'9'){
        c=gc();
    }
    while(c>='0' && c<='9'){
        n=(n<<3)+(n<<1)+c-'0';
        c=gc();
    }
    return n;
}
*/
//...................................

//power with mod........long long int
 ll power(ll a,ll b,ll mod){
      if(b==0)
            return 1;
      ll temp=power(a,b/2,mod);
      temp=(temp*temp)%mod;
      if(b&1)
            temp=(temp*a)%mod;
      return temp;
}

 //power without mod........ int
ll pwr(ll a,ll b){
      if(b==0)
            return 1;
      ll temp=pwr(a,b/2);
      temp=(temp*temp);
      if(b&1)
            temp=(temp*a);
      return temp;
}
 // .....long long int
ll gcd(ll a,ll b){
      return b==0?a:gcd(b,a%b);
}
 //......long long int
ll lcm(ll a,ll b){
      return (a/gcd(a,b))*b;
}
 //......long long int with mod
ll modularInverse(ll a,ll m){
      return power(a,m-2,m);
}

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

//normal compare func on integers //for qsort(name,size,sizeof(type),compare)
int compare (const void * a, const void * b)
{
  return ( *(int*)a - *(int*)b );
}

int BinarySearch(int *array, int number_of_elements, int key)
{
        int low = 0, high = number_of_elements-1, mid;
        while(low <= high)
        {
                mid = (low + high)/2;
                if(array[mid] < key)
                {
                        low = mid + 1;
                }
                else if(array[mid] == key)
                {
                        return mid;
                }
                else if(array[mid] > key)
                {
                        high = mid-1;
                }

        }
        return -1;
}
//.......................................................

//segment tree
//not template but how to use ST
//for minimum element
/*
long long s[400000];
long long a[1000000];
int create(long long b,long long e,long long n)
{
    if(b==e)
    {
        s[n]=a[b];
    }
    else
        {
            create(b,(b+e)/2,2*n+1);
            create((b+e)/2+1,e,2*n+2);
            s[n]=s[2*n+1]<s[2*n+2]?s[2*n+1]:s[2*n+2];
        }
    return 0;
}

//for finding minimum element b/w l and r
long long messi(long long b,long long e,long long l,long long r,long long n)
{
    long long i,j;
    if(e<l||b>r)
    {
        return 100000001;
    }
    if(b>=l&&e<=r)
    {
        return s[n];
    }
    i=messi(b,(b+e)/2,l,r,2*n+1);
    j=messi((b+e)/2+1,e,l,r,2*n+2);
    return i<j?i:j;
}
*/
//............................................................................
//range minimam query
//for mim and max number
/*

//preprocess create the min array

long min[SQRTMAX], max[SQRTMAX], b[MAX];
int size, n;

void preProcess(int n){
    int i=0, j=0, k=0;
    long minimum, maximum;

    size = sqrt(n);
    //printf("size = %d\n",size);
    while(j<size){
        minimum = maximum = b[i];
        for(k=0 ; k<size ; k++){
            if(minimum>b[i])
                minimum = b[i];
            if(maximum<b[i])
                maximum = b[i];
            i++;
        }
        min[j] = minimum;
        max[j] = maximum;
        j++;
    }
}

long findMin(int l, int r){
    int j, j2;
    long minimum = b[l];

    j = l/size + 1;
    j2 = r/size - 1;

    //printf("j= %d and j2 = %d\n", j,j2);
    while(l<j*size && l<=r){
        if(minimum > b[l]){
            minimum = b[l];

        }
        //printf("Checked for %d\n", l);
        l++;
    }
    while(j<=j2 && l<=r && j<size){
        if(minimum > min[j])
            minimum = min[j];
        l = (j+1)*size;
        //printf("Checked for %d  <-->  %d\n", j*size, l-1);
        j++;
    }
    while(l<=r){
        if(minimum > b[l]){
            minimum = b[l];
        }
        //printf("Checked for %d\n", l);
        l++;
    }
    return minimum;
}

//finding max value
long findMax(int l, int r){
    int j, j2;
    long maximum = b[l];

    j = l/size + 1;
    j2 = r/size - 1;

    //printf("j= %d and j2 = %d\n", j,j2);
    while(l<j*size && l<=r){
        if(maximum < b[l]){
            maximum = b[l];

        }
        //printf("Checked for %d\n", l);
        l++;
    }
    while(j<=j2 && l<=r && j<size){
        if(maximum < max[j])
            maximum = max[j];
        l = (j+1)*size;
        //printf("Checked for %d  <-->  %d\n", j*size, l-1);
        j++;
    }
    while(l<=r){
        if(maximum < b[l]){
            maximum = b[l];
        }
        //printf("Checked for %d\n", l);
        l++;
    }
    return maximum;
}
*/

//...........................................END OF TEMPLATE.................................................................
ll flen(ll b)
{
    ll len=0;
    while(b!=0)
      {
          b=b>>1;
          len++;
      }

      return len;

}

ll arr[70];
int main()
{ ll i,j,k,t,n,len,tot=0,f1=0,f2=0,a,b,ans=0,f3=0;

  sl(a)
  sl(b)

  len= flen(b);

  //pl(len)

  if(((a>>(len-1))&1)==((b>>(len-1))&1))
  {
      arr[tot++]=0;
  }

  else
  {
     arr[tot++]=1;

      if(((a>>(len-1))&1)==0 && ((b>>(len-1))&1)==1)
        f3=1;
  }

  i=len-2;

  while((((a>>(i))&1)==((b>>(i))&1))&& f3==0 && i>=0)
  {
      arr[tot++]=0;
      i--;
  }

  for(;i>=0;i--)
  {
      if(f1==1  || f2==1)
      {
          arr[tot++]=1;
      }

      else
      {
          if(((a>>i)&1)==0)
         {
             if(((b>>i)&1)==0)
             {
                 arr[tot++]=1;
                 f1=1;
             }
             else
             {
                 arr[tot++]=1;
                 f1=f2=1;
                 f3=1;
             }

         }
         else
         {
              if(((b>>i)&1)==0)
             {
                 arr[tot++]=1;
                // f1=1;
             }
             else
             {
                 arr[tot++]=1;
                 f2=1;
             }
         }

      }
  }

//pl(tot)
  FOR(i,0,tot)
  {
      ans=ans+arr[i]*pwr(2,tot-i-1);
  }

  pl(ans)

    return 0;
}


#include<stdio.h>
int  main()
 {
 long long l,r,t,w;
 while(scanf("%lld%lld",&l,&r)!=EOF)
 {
   if(r==l)printf("0\n");
   else
   {w=0;
 	   while(r!=l&&r!=0)
 	   {
		  w++;
		  l=l>>1;
 	   	  r=r>>1;
 	   }
		t=1;
 	   while(w--)t=t*2;
 	   printf("%lld\n",t-1);
   }
 }
   return 0;
 }


#include <stdio.h>
#include <stdlib.h>
int n;
long long S;
int main()
{
    scanf("%d",&n);
    scanf("%lld",&S);
    if(S%n==0)
        printf("%lld",S/n);
    else
        printf("%lld",S/n+1);

    return 0;
}


#include <stdio.h>
//ko gioi han gia tri
// co nhieu tien cung gia tri
int main()
{
	long n,s;
	scanf("%ld%ld",&n,&s);
	long cnt=0,tmp;
	while(n>0)
	{
		if(s==0){
			break;
		}
		tmp=s/n;
		cnt=cnt+tmp;
		s=s-tmp*n;
		n=n-1;
	}
	printf("%ld",cnt);
	return 0;
}


#include <stdio.h>

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

int sum2(int n) {
	return n * (n + 1) * (n + n + 1) / 6;
}

int main() {
	int n;

	scanf("%d", &n);
	printf("%d\n", sum2(n - 1) - 1 + sum1(n - 1) - 1);
	return 0;
}


#include<stdio.h>
#define MAX 987654321
int n;

int main()
{
	scanf("%d", &n);
	if (n < 3)    //when polygon has less than 3 points
		return 0;
	int table[501][501];

	for (int gap = 0; gap < n; gap++) {
		for (int i = 0, j = gap; j < n; i++, j++) {
			if (j < i + 2)
				table[i][j] = 0;
			else {
				table[i][j] = MAX;

				for (int k = i + 1; k < j; k++) {
					int val = table[i][k] + table[k][j] + (i+1)*(j+1)*(k+1);
					if (table[i][j] > val)
						table[i][j] = val;    //update table data to minimum value
				}
			}
		}
	}
	printf("%d\n", table[0][n - 1]);
	return 0;
}


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

        if(sum>n)
        break;
        l++;
    }
    printf("%d",l);
}


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


#include <stdio.h>
#include <string.h>
int main ()
 {
     char s[50];
     int count=0,a;
     scanf("%s",s);

     for(int i=0;i<strlen(s);i++)
     {

         if(s[i]=='a')
            count++;

     }
     int uncount=strlen(s)-count;
     if(count > uncount)
     {
        printf("%d",strlen(s));
     }
     else
     {
       uncount-=count;
       uncount++;
       printf("%d",strlen(s)-uncount);
     }
 }


#include <stdio.h>
#include <string.h>
int main()
{
    char string[51];
    int length,l,i,c=0;
    scanf("%s",string);
    length=strlen(string);
    l=length/2;
    for(i=0;i<length;i++)
    {
        if(string[i]=='a')
        {
            c+=1;
        }
    }
    if(c>l)
    {
        printf("%d",length);
    }
    else
    {
        printf("%d",(c*2)-1);
    }
    return 0;
}


#include "stdio.h"

int main ()
{
	int k,max=-1;
	int r[26];
	scanf("%d",&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%d",&r[i]);
	}
	for(int i=1;i<=k;i++)
	{
		if (max<r[i])
		max=r[i];
	}
	if(max<=25)
	{
		printf("0");
	}
	else
	{
		printf("%d",max-25);
	}
}


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

	return 0;
}


#include<stdio.h>
int main()
{
	char a[101];
	int n,al[130]={0},number,count=0;
	scanf("%d",&n);
	scanf("%s",a);
	for(int i=0;i<n;i++)
	{
		if(a[i]<='Z')
			a[i]=a[i]+32;
		if(al[a[i]]==0)
		{
			count++;
			al[a[i]]++;
		}
	}

	if(count==26)
		printf("YES");
	else
		printf("NO");
 }


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

	char s[50];
	scanf("%s",s);
	int l=strlen(s);
	int count=0;
	int cs=0;
	for(int i=0;i<l/2;i++){
		if(s[i] != s[l-1-i])
			count +=1;
	}
	if(count !=0)
		printf("%d",l);
	else
		{
			for(int i=1;i<l;i++)
			{
				if(s[i]==s[i-1])
					cs++;
		    }
		    if(cs==(l-1))
				printf("%d",0);
			else
				printf("%d",l-1);

		}

}


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

int main(){
    char a[50];
    scanf("%s", a);

    int l;
    l=strlen(a);
    int i=0, flag=0, flag2=0;
    int j = l-1;
    int k=j;

    for(int i=0;i<=l-1;i++){
    if(a[0]!=a[i]){
     flag2=1;
        }
    }
    if(flag2==1){
 while(i<j){
     if(a[i]!=a[j]){
  flag=1;
  break;
     }
  i = i + 1;
  j = j - 1;
 }
    }
    if(flag==0 && flag2==1){
 printf("%d\n",k);
    }

    if(flag==1 && flag2==1){
 printf("%d\n",l);
    }
    if(flag2==0){
 printf("0\n");
    }
    return 0;

}


#include <stdio.h>
#include <string.h>
int main()
{
	int a, i;
	char A[105];
	scanf("%d", &a);
	scanf("%s", A);
	for (i = 0; i<a; i++){
		if (i == 0 || A[i] == '0'){
			printf("%c", A[i]);

		}

	}
	printf("\n");
	return 0;
}


#include<stdio.h>
int main() {
	int k;
	scanf("%d",&k);
	//一只手可以按k个键！
	char panel[4][5];
	int i,j;
	for(i=0;i<4;i++){
		scanf("%s",panel[i]);
	}
	//这里只需要做一个统计就可以！
	int count[10];
	for(i=0;i<10;i++){
		count[i]=0;
	}
	for(i=0;i<4;i++){
		for(j=0;j<4;j++){
			if(panel[i][j]!='.'){
				count[panel[i][j]-'0']++;
			}
		}
	}
	for(i=1;i<10;i++){
		if(count[i]>2*k){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int k,i,b[10],j,pd;
    char a[4][4];
while(scanf("%d",&k)!=EOF)
{
    getchar();
    memset(b,0,sizeof(b));
    for(i=0;i<4;i++){
    for(j=0;j<4;j++)
    {
        scanf(" %c",&a[i][j]);
        if(a[i][j]>='1'&&a[i][j]<='9')
        b[a[i][j]-'0']++;
    }
     getchar();
    }
    pd=0;
    for (i=1;i<=9;i++) if (b[i]>2*k) pd=1;
    if(pd) printf("NO\n");
    else printf("YES\n");
}
    return 0;
}


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


#include<stdio.h>
int main(void)
{
    int n;
    scanf("%d",&n);
    printf("%d\n",3*n/2);

    return 0;
}


// C program for array implementation of queue
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

// A structure to represent a queue
struct Queue
{
    int front, rear, size;
    unsigned capacity;
    int* array;
};

// function to create a queue of given capacity. It initializes size of
// queue as 0
struct Queue* createQueue(unsigned capacity)
{
    struct Queue* queue = (struct Queue*) malloc(sizeof(struct Queue));
    queue->capacity = capacity;
    queue->front = queue->size = 0;
    queue->rear = capacity - 1;  // This is important, see the enqueue
    queue->array = (int*) malloc(queue->capacity * sizeof(int));
    return queue;
}

// Queue is full when size becomes equal to the capacity
int isFull(struct Queue* queue)
{  return (queue->size == queue->capacity);  }

// Queue is empty when size is 0
int isEmpty(struct Queue* queue)
{  return (queue->size == 0); }

// Function to add an item to the queue.  It changes rear and size
void enqueue(struct Queue* queue, int item)
{
    if (isFull(queue))
        return;
    queue->rear = (queue->rear + 1)%queue->capacity;
    queue->array[queue->rear] = item;
    queue->size = queue->size + 1;
    //printf("%d enqueued to queue\n", item);
}

// Function to remove an item from queue.  It changes front and size
int dequeue(struct Queue* queue)
{
    if (isEmpty(queue))
        return INT_MIN;
    int item = queue->array[queue->front];
    queue->front = (queue->front + 1)%queue->capacity;
    queue->size = queue->size - 1;
    return item;
}

// Function to get front of queue
int front(struct Queue* queue)
{
    if (isEmpty(queue))
        return INT_MIN;
    return queue->array[queue->front];
}

// Function to get rear of queue
int rear(struct Queue* queue)
{
    if (isEmpty(queue))
        return INT_MIN;
    return queue->array[queue->rear];
}

int main()
{
	int N;
	scanf("%d",&N);
	int k1;
	scanf("%d",&k1);
	struct Queue* queue1 = createQueue(N);
	int val;
	int i;
	for(i=0;i<k1;i++){
		scanf("%d",&val);
		enqueue(queue1, val);
	}
	int k2;
	scanf("%d",&k2);
	struct Queue* queue2 = createQueue(N);
	for(i=0;i<k2;i++){
		scanf("%d",&val);
		enqueue(queue2,val);
	}
	int moves = 0;
	int flag = 0;
	int lol;
	while(1)
	{
		moves++;
		int temp1;
		int temp2;
		temp1 = dequeue(queue1);
		temp2 = dequeue(queue2);
		if(temp1>temp2)
		{
			enqueue(queue1,temp2);
			enqueue(queue1,temp1);
		}
		else
		{
			enqueue(queue2,temp1);
			enqueue(queue2,temp2);
		}
		if(isEmpty(queue1) == 1){
			flag = 1;
			lol = 2;
			break;
		}
		else if(isEmpty(queue2) == 1){
			flag = 1;
			lol = 1;
			break;
		}
		if(moves > 362880)
			break;

	}
	if(flag == 1)
		printf("%d %d\n",moves,lol);
	else
		printf("-1\n");
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int x,a=0,j=0,b=0,i;
    char str[200];
    int ara[100];
    scanf("%d",&x);
    scanf("%s",str);
    str[x]='W';
    x++;
    for(i=0,j=0;i<x;i++)
    {
        if(str[i]=='B')
            a++;
        else if(str[i]=='W'&&str[i-1]=='B')
        {
            ara[j]=a;
            j++;
            a=0;
            b++;
        }
    }
    printf("%d\n",b);
    for(i=0;i<b;i++)
    {
        printf("%d ",ara[i]);
    }
    //printf("\n");

    return 0;
}


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

int main()
{
	int n,k=0,i,cnt,w,f=0;
	int a[1000];
	char str[1001];
	scanf("%d",&n);
	scanf("%s",str);

	cnt=0;
	for (i=0;i<n;i++){
		if (str[i]=='B'){
			f=1;
			cnt++;
		}
		else if (str[i]=='W'){

			if (cnt>0){
				a[k]=cnt;
				k++;
			}
			cnt=0;
		}
	}
	if (f==0){

		printf("0");
		return 0;
	}
	if (cnt>0){
	a[k]=cnt;
	k++;
	}
	printf("%d\n",k);
	for (i=0;i<k;i++){
		printf("%d ",a[i]);
	}
	return 0;
}


#include <stdio.h>
const long MOD = 1e9 + 7;

int main(void)
{
    long i, n;
    long long a = 0, b = 1, c;
    scanf("%ld", &n);
    for (i = 1; i < n; i++) {
        c = a;
        a = (3 * b) % MOD;
        b = (2 * b + c) % MOD;
    }
    printf("%ld", a);
    return 0;
}


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

int main()
{
	int n, i, j,temp;
	char a[210];

	scanf("%d", &n);
	scanf("%s", a);
	for (i = 0; i < n; i++)
	{
		for (j = i + 1; j < n; j++)
		{
			if (a[i]>a[j])
			{
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}

		}
	}
	for (; i < 2*n; i++)
	{
		for (j = i + 1; j < 2*n; j++)
		{
			if (a[i]>a[j])
			{
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}

		}
	}
	if (a[0] > a[n])
	{
		for (i = 0, j = n; i < n; i++, j++)
		{
			if (a[i] <= a[j])
				break;
		}
		if (i == n)
			printf("YES");
		else
			printf("NO");
	}
	else if (a[0] < a[n])
	{
		for (i = 0, j = n; i < n; i++, j++)
		{
			if (a[i] >= a[j])
				break;
		}
		if (i == n)
			printf("YES");
		else
		printf("NO");
	}
	else
		printf("NO");
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void scanp(const int len);
int comp (const void * elem1, const void * elem2);

int main()
{
    int len;
    scanf("%d", &len);
    leercomparar(len);
    return 0;
}

void leercomparar(const int len)
{
    char s[len * 2], s1[len + 1], s2[len + 1];

    scanf("%s", s);
    s1[len] = s2[len] = 0;

    qsort(strncpy(s1, s, len), len, sizeof(char), comp );
    qsort(strncpy(s2, s + len, len), len, sizeof(char), comp );

    for( int i = 0; i < len -1; i++ )
    {
        if ( comp(s1+i, s2+i) != comp(s1+i+1, s2+i+1)  || *(s1+i) == *(s2+i) )
        {
            puts("NO");
            return;
        }
    }

    if ( *(s1) == *(s2) )
        {
            puts("NO");
            return;
        }
    puts("YES");

}

int comp (const void * elem1, const void * elem2)
{
    char f = *((char*)elem1);
    char s = *((char*)elem2);
    if (f > s) return  1;
    if (f < s) return -1;
    return 0;
}


#include <stdio.h>

int main(){
    int n,indexOne=1,indexTwo=1,indexThree=0,temp;
    scanf("%d",&n);
    int gameArr[n+1],inp;
    for(int i=0;i<n;i++){
        scanf("%d",&inp);
        gameArr[i]=inp;
    }
    if(gameArr[0]==3){
        printf("NO");
        return 0;
    }else if(n>=2){
        if((gameArr[0]==1 && gameArr[1]==2)||(gameArr[0]==2 && gameArr[1]==1)){
        printf("NO");
        return 0;
        }
        for(int i = 0; i < n-2 ; i++){
            if(gameArr[i]==gameArr[i+2] && gameArr[i]!=gameArr[i+1]){
                printf("NO");
                return 0;
            }
        }
    }
    temp=indexOne;
    for(int i = 0; i<n;i++){
        if(gameArr[i]==1){
            temp = indexOne;
            indexOne++;
            indexOne=indexOne%2;
        }
        if(gameArr[i]==1 && i%2==temp){
            printf("NO");
            return 0;
        }
    }
    temp=indexTwo;
    for(int i = 0; i<n;i++){
        if(gameArr[i]==2){
            temp=indexTwo;
            indexTwo++;
            indexTwo=indexTwo%2;
        }
        if(gameArr[i]==2 && i%2==temp){
            printf("NO");
            return 0;
        }
    }
    temp = indexThree;
    for(int i = 0; i<n;i++){
        if(gameArr[i]==3){
            temp = indexThree;
            indexThree++;
            indexThree = indexThree%2;
        }
        if(gameArr[i]==3 && i%2==temp){
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;
}


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

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

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

int main()
{
	int i,n,a[105],j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	if(a[0]==3)
	{
		printf("NO\n");
		return 0;
	}
	int k,l=0,val=1;
	int count[4]={0};
	count[a[0]]=1;
	count[3]=1;
	for(i=1;i<n;i++)
	{
		for(j=1;j<=3;j++)
		{
			if(count[j]==0)
			{
				if(a[i]==j)
				{
					val=0;
					break;
				}
				else
				{
					k=j;
				}
			}
			else
			{
				if(a[i]!=j)
				{
					l=j;
				}
			}
		}
		if(val!=0)
		{
			count[l]=0;
			count[k]=1;
		}
	}
	if(val==0)
		printf("NO\n");
	else
		printf("YES\n");
	return 0;
}


#include <stdio.h>

int main()
{
    int n, m, i, j, temp, min = 99999;
    scanf("%d %d", &n, &m);
    int arr[m];

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

    for(i=0; i<m-1; i++){
        for(j=0; j<m-1; j++){
            if(arr[j] > arr[j+1]){
                temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = temp;
            }
        }
    }

    j = arr[m-1] - arr[0];
    for(i=0; i<m-n+1; i++){
        if(arr[i+n-1] - arr[i] < j){
            j = arr[i+n-1] - arr[i];
        }
    }

    printf("%d", j);

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n,m,i,j,p[50]={0},min=1000000,cur,temp;
	scanf("%d %d",&n,&m);
	for (i=0;i<m;i++)
		scanf("%d",&p[i]);
	for (i=0;i<m;i++)
		for (j=0;j<m-i-1;j++)
			if (p[j]>p[j+1])
			{
				temp=p[j];
				p[j]=p[j+1];
				p[j+1]=temp;
			}
	for (i=0;i<m-n+1;i++)
	{
		cur=p[i+n-1]-p[i];
		if (cur<min)
			min=cur;
	}
	printf("%d\n",min);
	return 0;
}


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


#include<stdio.h>

int main()
{
    int n,a,b,p;
    scanf("%d %d %d",&n,&a,&b);
    if((a+b)<n)    p = b+1;
    else if((a+b)==n)    p = b;
    else    p = n-a;
    printf("%d\n",p);
    return 0;
}


/* https://codeforces.com/blog/entry/70162 */
#include <stdio.h>

#define N	250
#define MD	1000000007

long long power(int a, int k) {
	long long b = a, p = 1;

	while (k > 0) {
		if (k & 1)
			p = p * b % MD;
		b = b * b % MD;
		k >>= 1;
	}
	return p;
}

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

void init() {
	int i;
	long long f = 1;

	for (i = 0; i <= N; i++) {
		gg[i] = power(ff[i] = f, MD - 2);
		f = f * (i + 1) % MD;
	}
}

long long choose(int n, int k) {
	return (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

int main() {
	int n, k, r, ans;

	init();
	scanf("%d%d", &n, &k);
	ans = 0;
	for (r = 0; r <= n; r++)
		ans = (ans + (r % 2 == 0 ? 1 : -1) * choose(n, r) * power(power(k - 1, r) * (power(k, n - r) - power(k - 1, n - r)) % MD, n)) % MD;
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


#include<stdio.h>
#define MOD 1000000007

int dar[252][252], k, n, fact[252], inv[252], precomp[2][252];

int add(int a, int b){
  a += b;
  if(a >= MOD)a -= MOD;
  return a;
}

int mul(int a, int b){
  return (a*1ll*b)%MOD;
}
int powmod(int base, long long p){
  int toret = 1;
  while(p){
    if(p&1)toret = mul(toret, base);
    base = mul(base, base);
    p >>= 1;
  }
  return toret;
}

int ncr(int n, int r){
  return mul(mul(fact[n], inv[r]), inv[n - r]);
}

int dp(int r, int c){
  //  printf("dp(%d, %d)\n", r, c);
  if(dar[r][c] == -1){
    int toret = 0;
    if(r == 0){
      dar[r][c] = (c == 0);
      return dar[r][c];
    }

    int sat = n - c;
    int i;
    for(i = 0;i <= c;i++)if(i + sat){
      int f1 = precomp[0][c - i];
      f1 = mul(f1, ncr(c, i));
      int f2 = precomp[1][sat];
      if(i == 0){
	f2 = add(f2, MOD - precomp[0][sat]);
      }
      toret = add(toret, mul(dp(r - 1, c - i), mul(f1, f2)));
    }
    dar[r][c] = toret;
  }
  return dar[r][c];
}

int main(){
  scanf("%d %d", &n, &k);
  if(k == 1){
    printf("1\n");
    return 0;
  }
  int i,j;
  fact[0] = 1;
  inv[0] = 1;
  precomp[0][0] = precomp[1][0] = 1;
  for(i = 1;i < 252;i++){
    fact[i] = mul(fact[i - 1], i);
    inv[i] = powmod(fact[i], MOD - 2);
    precomp[0][i] = powmod(k - 1, i);
    precomp[1][i] = powmod(k, i);
  }
  for(i = 0;i <= n;i++)for(j = 0;j <= n;j++){
      dar[i][j] = -1;
    }
  printf("%d\n", dp(n, n));
  return 0;
}


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

int main()
{
        int n,d,m,s=0,s1=0,i;
        scanf("%d%d",&n,&d);
        int a[n];
        for(i=0;i<n;i++) { scanf("%d",&a[i]); s=s+a[i]; }
        scanf("%d",&m);
        qsort(a,n,sizeof(int),cmp);
        if(m<n)
        { for(i=0;i<m;i++)  s1=s1+a[i]; printf("%d",s1); exit(0); }
        else s=s-d*(m-n); printf("%d",s);
        return 0;
}


#include<stdio.h>
main()
{
    int x,y=5,p,q,r,s;
        scanf("%d",&x);

        if(x<y)
        {
            p=x%y;
            q=p/p;
            printf("%d\n",q);
        }

        else if(x>=y)
            {
                if(x%y==0)
                {
                    r=x/y;
                     printf("%d\n",r);
                }

                 else
        {
            s=(x/y)+1;
            printf("%d\n",s);
        }
            }

        return 0;
}


#include <stdio.h>

int main()
{
	int x,hh,mm;
	int h,m;
	int a,i;

	scanf("%d", &x);
	scanf("%d %d", &hh, &mm);

	for(i=0; ; i++)
	{
	    h=hh%10;
		m=mm%10;

		mm=mm-x;
		if(mm<0)
		{
			mm=mm+60;
			hh=hh-1;
		}
		if(hh<0)
		{
			hh=hh+24;
		}

		if(h==7 || m==7 || (hh==7 && mm==0) )
		{
			break;
		}
	}
	printf("%d\n", i);
	return 0;
}


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

	int x, hours,minutes;
	scanf("%i",&x);
	scanf("%d%d",&hours,&minutes);
	int newHour = minutes;
	int minus;
	int counter = 0 ;
	while (1){

		if (newHour % 10 == 7 || hours % 10 == 7 ){
			break;
		}

		if(hours == 0){
			hours = 24;
		}

		if (newHour < x){
			minus = x - newHour;
			newHour = 60 - minus;
			hours -=1;
		}

		else
		{
			newHour -=  x;
		}
		counter += 1;

	}
	printf("%i",counter);

}


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


#include <stdio.h>
int main()
{
	int n,k,x,ans;
	scanf("%d %d %d",&n,&k,&x);
	int i,arr[n],sum=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);
		if(i<n-k)
			sum=sum+arr[i];
	}
    ans=sum+k*x;
	printf("%d\n",ans);
	return 0;
}


#include<stdio.h>
int main()
{
    char s[10][10];
    int i,j,cnt=0,t,x=0;
    for(i=0;i<8;i++){
        gets(s[i]);
        t=0;
        for(j=0;j<8;j++)
            if(s[i][j]=='B')t++;
        if(t==8)cnt++;
        else x=t;
    }
    cnt+=x;
    printf("%d\n",cnt);
    return 0;
}


#include <stdio.h>
#include<math.h>
int main()
{
	int n,mi=0,max=0,sum=0,sum1=0;
	scanf("%d",&n);
	int a[n];
	for(int i=0; i<n; i++)
	{
		scanf("%d",&a[i]);
		if(max>((i+1)*a[i]))
		{
			max=(i+1)*a[i];
			mi=i;

		}
	}
	int b=n-1;
	for(int j=0; j<n; j++)
	{
		sum= (j-mi) + (j-0) + 2*(mi-0) + abs(0-j) + abs(mi-j);
		sum1= sum1 + sum*a[j];
		sum=0;
	}
	printf("%d",sum1);
	return 0;

}


#include <stdio.h>
int mod(int,int);
int main()
{
	int n,a[100],el[100],min,x,i,u;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		el[i]=0;
	}
	for(x=0;x<n;x++)
	{
		for(i=0;i<n;i++)
		{
			u=2*(mod(i,x)+x+i);
			el[x]=el[x]+u*a[i];
		}
	}
	min=el[0];
	for(i=1;i<n;i++)
	{
		if(min>el[i])
		min=el[i];
	}
	printf("%d",min);

	return 0;
}
int mod(int i,int x)
{
	if(i>x)
	return i-x;
	else
	return x-i;
}


#include <stdio.h>
#include <stdlib.h>
#define rep(i,a,b) for (int i=a; i<b; i++)
typedef long long ll;
typedef struct {
    ll box,match;
} container;
void scan(container **arr, int length) {
    rep (i,0,length) arr[i]=(container*) malloc(sizeof(container));
    rep (i,0,length) scanf("%I64d %I64d\n",&(arr[i]->box),&(arr[i]->match));
}
void sort(container **arr, int length) {
    container *temp;
    rep (i,0,length-1) {
        rep (j,i+1,length) {
            if ((arr[i]->match)<(arr[j]->match)) {
                temp=arr[i];
                arr[i]=arr[j];
                arr[j]=temp;
            }
        }
    }
}
long min(ll x, ll y) {
    return (x<=y) ? x:y;
}
ll max_matches(container **arr, int length, long maximum) {
    ll res=0;
    long fill=0,next;
    int pos=0;
    while (pos<length && fill<maximum) {
        next=min(maximum,fill+arr[pos]->box);
        res+=(next-fill)*(arr[pos]->match);
        fill=next;
        pos++;
    }
    return res;
}
int main() {
    long maxsize;
    int m; scanf("%ld %d\n",&maxsize,&m);
    container *warehouse[m];
    scan(warehouse,m);
    sort(warehouse,m);
    printf("%I64d",max_matches(warehouse,m,maxsize));
    rep (i,0,m)  free(warehouse[i]);
    return 0;
}


#include <stdio.h>
int main()
{
    unsigned int No_Of_ur_Matches_Boxes;
    unsigned short No_Of_Containers;
    scanf("%u%hu", &No_Of_ur_Matches_Boxes, &No_Of_Containers);
    unsigned int No_Of_Matches_boxes_In_Container[No_Of_Containers];
    unsigned short No_Of_Matches_In_Matchesbox[No_Of_Containers];
    unsigned char i, j;
    for( i = 0; i < No_Of_Containers; i++){
        scanf("%u%hu", &No_Of_Matches_boxes_In_Container[i], &No_Of_Matches_In_Matchesbox[i]);
    }
    /* debug the input
    for( i = 0; i < No_Of_Containers; i++){
        printf("%u %hu \n", No_Of_Matches_boxes_In_Container[i], No_Of_Matches_In_Matchesbox[i]);
    }*/
    unsigned char Max_index;
    Max_index = 0;
    unsigned int Max_Matches = 0;
    if( 1 == No_Of_Containers){
      if( No_Of_ur_Matches_Boxes <= No_Of_Matches_boxes_In_Container[Max_index]){
            Max_Matches += No_Of_ur_Matches_Boxes * No_Of_Matches_In_Matchesbox[Max_index];
      }
      else{
            Max_Matches += No_Of_Matches_boxes_In_Container[Max_index] * No_Of_Matches_In_Matchesbox[Max_index];
      }
    } else{
    for( j = 0; j < No_Of_Containers; j++){
        for( i = 0; i < (No_Of_Containers-1); i++ ){
            if( No_Of_Matches_In_Matchesbox[Max_index] < No_Of_Matches_In_Matchesbox[i+1]){ Max_index = i+1; }
            else if( No_Of_Matches_In_Matchesbox[Max_index] == No_Of_Matches_In_Matchesbox[i+1]){
                if( No_Of_Matches_boxes_In_Container[Max_index] < No_Of_Matches_boxes_In_Container[i+1]){ Max_index = i+1; }
            }
        }
        if( No_Of_ur_Matches_Boxes <= No_Of_Matches_boxes_In_Container[Max_index]){
            Max_Matches += No_Of_ur_Matches_Boxes * No_Of_Matches_In_Matchesbox[Max_index];
            break;
        }
        else{
            Max_Matches += No_Of_Matches_boxes_In_Container[Max_index] * No_Of_Matches_In_Matchesbox[Max_index];
            No_Of_ur_Matches_Boxes -= No_Of_Matches_boxes_In_Container[Max_index];
            No_Of_Matches_In_Matchesbox[Max_index] = 0;
            No_Of_Matches_boxes_In_Container[Max_index] = 0;
            Max_index = 0;
        }
    }
 }
    printf("%u", Max_Matches);

    return 0;
}


#include <stdio.h>
#define MAX(a, b) (((a)>(b))?(a):(b))

char grid[3][4];

int adj(int x, int y){
    int i,j,max;
    char t;
    max=-1;
    t=grid[x][y];
    for(i=0; x+i<3&&grid[x+i][y]==t; ++i);
    max=MAX(max, i);
    for(i=0; x-i>-1&&grid[x-i][y]==t; ++i);
    max=MAX(max, i);
    for(j=0; y+j<3&&grid[x][y+j]==t; ++j);
    max=MAX(max, j);
    for(j=0; y-j<3&&grid[x][y-j]==t; ++j);
    max=MAX(max, j);
    for(i=0; x+i<3&&y+i<3&&grid[x+i][y+i]==t; ++i);
    max=MAX(max, i);
    for(i=0; x+i<3&&y-i>-1&&grid[x+i][y-i]==t; ++i);
    max=MAX(max, i);
    for(j=0; x-j>-1&&y+j<3&&grid[x-j][y+j]==t; ++j);
    max=MAX(max, j);
    for(j=0; x-j>-1&&y-j>-1&&grid[x-j][y-j]==t; ++j);
    max=MAX(max, j);
    return max;
}

int verdict(void){
    int i,j,p,d,f,s;
    d=f=s=0;
    for(i=0; i<3; ++i)
        for(j=0; j<3; ++j){
            if(grid[i][j]=='.')
                d=3;
            p=adj(i,j);
            if(p==3){
                if(grid[i][j]=='X')
                    f=1;
                else if(grid[i][j]=='0')
                    s=1;
            }
        }
    if(f&&s)
        d=-1;
    else if(f)
        d=1;
    else if(s)
        d=2;
    return d;
}

int place(void){
    int i,j,f,s;
    for(f=s=i=0; i<3; ++i)
        for(j=0; j<3; ++j){
            if(grid[i][j]=='X')
                ++f;
            else if(grid[i][j]=='0')
                ++s;
        }
    if(f==s)
        return 1;
    else if(f-s==1)
        return 2;
    else
        return 0;
}

int main(void){
#ifndef ONLINE_JUDGE
    freopen("3C.in", "rb", stdin);
#endif
    int i,v,p;
    for(i=0; i<3; ++i)
        scanf("%s", grid[i]);
    v=verdict();
    p=place();
    if(!p||(p==1&&v==1)||(p==2&&v==2))
        v=-1;
    switch(v){
        case -1: printf("illegal\n"); break;
        case 0: printf("draw\n"); break;
        case 1: printf("the first player won\n"); break;
        case 2: printf("the second player won\n"); break;
        case 3: printf("%s\n", p==1?"first":"second"); break;
    }
#ifndef ONLINE_JUDGE
    fclose(stdin);
#endif
    return 0;
}


#include<stdio.h>
int main()
{
    int n, a[100], i, j, k, l, max, min =100000, del;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    l=2;
    for(j=1;j<=n-2;j++)
    {
        del = a[l]; max=0;
        for(i=2;i<=n-1;i++)
        {
            if(a[i]==del)
                k = a[i+1]-a[i-1];
            else
                k= a[i+1]-a[i];
           if(k>max)
            max=k;
        }

        if(max<min)
            min=max;
        l++;
    }
    printf("%d\n",min);
    return 0;
}


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

void identificar_posicion(char *pos,int *a,int *b);
void recorrido_caballo(int mat[][8],int f,int c);
void recorrido_torre(int mat[][8],int f,int c);
//void imprimir_mat(int mat[][8]);

int main()
{
    int mat[8][8];
    char pos[3];
    int i,j,ft,ct,fk,ck,cant=0;
    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
        {
            mat[i][j]=0;
        }
    }
    scanf("%s",pos);
    identificar_posicion(pos,&ft,&ct);
    scanf("%s",pos);
    identificar_posicion(pos,&fk,&ck);
    recorrido_torre(mat,ft,ct);
    recorrido_caballo(mat,fk,ck);
    recorrido_caballo(mat,ft,ct);
    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
        {
            if(!mat[i][j])
            {
                cant++;
            }
        }
    }

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

/*void imprimir_mat(int mat[][8])
{
    int i,j;
    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
        {
            printf("%2d",mat[i][j]);
        }
        printf("\n\n");
    }
}*/

void recorrido_caballo(int mat[][8],int f,int c)
{
    int i,fila=0,columna=0;
    mat[f][c]=-2;/*cambiar a -1*/
    int vec[16]={-1,-2,-2,-1,-2,1,-1,2,1,2,2,1,2,-1,1,-2};
    for(i=0;i<16;i+=2)
    {
        fila=f+vec[i];
        columna=c+vec[i+1];

        if(0<=fila && 0<=columna && fila<8 && columna<8)
        {
            mat[fila][columna]=-1;
        }
    }
}

void recorrido_torre(int mat[][8],int f,int c)
{
    int i;
    mat[f][c]=-2;/*cambiar a -1*/
    for(i=0;i<8;i++)
    {
        mat[f][i]=-1;
        mat[i][c]=-1;
    }
}

void identificar_posicion(char *pos,int*a, int*b)
{
    int i;
    char cadena[9]="abcdefgh";
    for(i=0;cadena[i];i++)
    {
        if(pos[0]==cadena[i])
        {
             *a=i;
        }
    }
    *b=atoi(&pos[1])-1;
}


#include <stdio.h>
#include<math.h>
int main(void) {
    int bl,br,gl,gr;
    scanf("%d %d %d %d",&gl,&gr,&bl,&br);
    if(abs(bl-gr)<2||abs(br-gl)<2)  printf("YES");
    else if((bl<=2*gr+2&&bl>gr)||(br<=2*gl+2&&br>gl))   printf("YES");
    else    printf("NO");
    return 0;
}


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

int main(){
    int al,ar,bl,br;
    scanf("%d %d",&al,&ar);
    scanf("%d %d",&bl,&br);
    if ( ((bl-1)/2 <= ar) &&(bl >= ar-1))
        printf("YES\n");
    else if ( ((br-1)/2 <= al) &&(br >= al-1))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


#include<stdio.h>
int main()
{
    int a,b,k1,k2,total,min=0,max=0;
    scanf("%d%d%d%d%d",&a,&b,&k1,&k2,&total);

    if((k1-1)*a + (k2-1)*b >=total)
    min=0;
    else
    min=total-((k1-1)*a +(k2-1)*b);

    if(k1<=k2)
    {
        if(k1*a>total)
        {
            max=total/k1;
            if(max>a)
            {
                total=total-(a*k1);
                max=a;}
            else
            total=total-(max*k1);

            max+=total/k2;
        }
        else
      {  max=a;

        total=(total-(k1*a));

        max+=total/k2;}

    }
    else
    {
        if(k2*b>total)
        {
            max=total/k2;
            if(max>b)
            {
                total=total-(b*k2);
                max=b;}
            else
            total=total-(max*k2);

            max+=total/k1;
        }
        else
      {  max=b;

        total=(total-(k2*b));
        max+=total/k1;}
    }
    printf("%d %d",min,max);

}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define max(l,r) ((l)>(r)?(l):(r))
#define min(l,r) ((l)<(r)?(l):(r))
#define chmax(l,r) (l=max(l,r))
#define chmin(l,r) (l=min(l,r))
const ll MOD = 1000000007;
const int INF = (1 << 30);      // > 10^9

int main(){
    int a1,a2,k1,k2,n;
    scanf("%d%d%d%d%d",&a1,&a2,&k1,&k2,&n);

    ll ansmx = 0, ansmn = 0;
    int tmp = n - (k1-1)*a1 - (k2-1)*a2;
    if(tmp < 0) ansmn = 0;
    else ansmn = tmp;

    tmp = 0;
    if(k1*a1 > n){
        tmp += n/k1;
    }else{
        tmp += a1;
        tmp += (n-k1*a1)/k2;
    }
    ansmx = 0;
    if(k2*a2 > n){
        ansmx += n/k2;
    }else{
        ansmx += a2;
        ansmx += (n-k2*a2)/k1;
    }
    chmax(ansmx, tmp);

    printf("%lld %lld\n", ansmn, ansmx);
    //if(ans){ puts("YES"); rep(i,n) printf("%lld ", a[i]);}else puts("NO");
}


#include <stdio.h>
long long int combination(long long int n,long long int r)
{
    long long int result=1,i=1;
    while(i<=r)
    {
        result=result*n/i;
        n--;
        i++;
    }
    return result;
}
int main()
{
    long long int n,m,t,result=0,i;
    scanf("%I64d %I64d %I64d",&n,&m,&t);
    i=t-4;
    while(i>0)
    {
        result=result+combination(n,t-i)*combination(m,i);
        i--;
    }
    printf("%I64d",result);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
long long ncr(long long n,long long r)
{
	if(r>(n-r))
		r=n-r;
	long long i,ret1=1,ret2=1,ret,j;
	int div[20]={0};
	div[1]=1;
	div[0]=1;
	for(i=0;i<r;i++)
	{
		ret1*=(n-i);
		for(j=2;j<=r;j++)
		{
			if(!(ret1%j) && !div[j])
				{
					ret1/=j;
					div[j]=1;
				}
		}
	}
	for(i=1;i<r;i++)
		if(!div[i])
			ret2*=(i+1);
	ret=ret1/ret2;
	//printf("%lld\n",ret);
	return ret;
}
int main()
{
	long long int ans=0,n,m,k;
	long long initb,initg;
	scanf("%lld%lld%lld",&n,&m,&k);
	if(n>=(k-1))
	{
		initb=k-1;
		initg=1;
	}
	else
	{
		initb=n;
		initg=k-n;
	}
	for(;initb>=4 && initg<=m ;initb--,initg++)
		ans+=((ncr(n,initb))*(ncr(m,initg)));
	printf("%lld\n",ans);
	return 0;
}


#include<stdio.h>
int main()
{
    int x;
    scanf("%d",&x);
    if(x==1 || x==2)
    printf("1");
    else {
        if(x%3==0)
        printf("%d",x/3*2);
        else {
            x=(int)x/3;
            x*=2;
            x++;
            printf("%d",x);
        }
    }
}


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


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#define  For(i,n)  for(i=0;i<n;i++);

typedef unsigned long long ull;
typedef  long ll;
char a[10];

int main()
{
ll t;
int i,n;
ll itr =0;
t=8;
 int s1=0,s2=0;
for(itr=1;itr<=t;itr++)
{
    scanf("%s",&a);
for(i=0;i<8;i++)
{
    if(a[i]=='q')s1=s1+9;
else     if(a[i]=='r')s1=s1+5;
else     if(a[i]=='b')s1=s1+3;
else     if(a[i]=='n')s1=s1+3;
else     if(a[i]=='p')s1=s1+1;
else     if(a[i]=='Q')s2=s2+9;
else     if(a[i]=='R')s2=s2+5;
else     if(a[i]=='B')s2=s2+3;
else     if(a[i]=='N')s2=s2+3;
else     if(a[i]=='P')s2=s2+1;
}
}
//printf("%d %d",s1,s2);
if(s1>s2)printf("Black");
if(s1==s2)printf("Draw");
if(s1<s2)printf("White");
return 0;
}


#include <stdio.h>

int main(){

	int a,b,c;

	scanf("%d",&a);

	if(a==1) puts("1");
	else{
		b = 1;
		c = 1;
		while(a!=1){
			if(a%2==1) c++;
			a/=2;
		}

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


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

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


/*
 * File:   main.c
 * Author: scawn
 *
 * Created on April 22, 2012, 3:26 AM
 */

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

/*
 *
 */
int main(int argc, char** argv) {
    int n;
    scanf("%d", &n);
    int sum = n;
    int i = 2;
    while (n > 1) {
        if (n % i == 0) {
            sum += n / i;
            n /= i;
            i = 2;
        } else {
            i++;
        }
    }
    printf("%d\n", sum);
    return (EXIT_SUCCESS);
}


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


#include <stdio.h>
#define min(a,b) a<b ? a : b

int main()
{
    int n, k, a;
    scanf("%d%d", &n,&k);
    a = 3*n +(min(n-k,k-1));
    printf("%d\n", a);
    return 0;
}


#include<stdio.h>
int min(int a, int b){return (a<b)?a:b;};

int main(){

	int n, m;
	scanf("%d %d", &n, &m);
	m = min(m, n-m+1);
	printf("%d", m*3+(m-1)+(n-m)*3);
	//3n+m-1
	return 0;
}


#include<stdio.h>

gcd(int a, int b)
{
    int c;

    if ( b == 0 )
        return a;

    else
        while ( b != 0 )
        {
            c = b;
            b = a % b;
            a = c;
        }

        return a;
}

int main()
{
	int a,b,c,d,a1,a2,a3;
	float m1,m2;
	scanf("%d%d%d%d",&a,&b,&c,&d);
    m1=(float)a/c;
    m2=(float)b/d;
//printf("%f %f\n",m1,m2);
if(m1<m2){
a1=(a*b*c-a*a*d);
a2=a*b*c;
}else{
a1=(a*b*d-b*b*c);
a2=a*b*d;
}
//printf("a1/a2 = %d/%d\n",a1,a2);

a3=gcd(a1,a2);
//printf("gcd = %d\n",a3);
a1/=a3;
a2/=a3;

printf("%d/%d",a1,a2);

    return 0;
}


#include<stdio.h>

int gcd(int a,int b)
{
    int r;

    while(a%b>0)
    {
        r=b;
        b=a%b;
        a=r;
    }
    return b;
}

int main()
{

    int a,b,c,d,k=1,Num,Den;
    scanf("%d %d %d %d",&a,&b,&c,&d);

    float r1=(float)a/(float)b,r2=(float)c/(float)d;

    if(r1==r2)
    {
        Num=0;
        Den=1;
        goto abc;
    }
    else if(r1>r2)
    {
        Num=a*d-b*c;
        Den=a*d;
    }
    else
    {
        Num=b*c-d*a;
        Den=b*c;
    }

    k=gcd(Num,Den);

    abc:

    printf("%d/%d",Num/k,Den/k);

    return 0;
}


#include<stdio.h>
int main()
{
    int n,i,num_x=0,m,remove=0;
    char s[101];
    scanf("%d",&n);
    scanf("%s",s);
    for(i=0; s[i]; i++)
    {
        if(s[i]=='x')
            num_x++;
        else
        {
            if(num_x>=3)
            {
                remove+=(num_x-2);
            }
            num_x = 0;
        }
    }
    if(num_x>=3)
    {
        remove+=(num_x-2);
    }

    printf("%d",remove);

    return 0;
}
//    6 xxxiii
//    5 xxoxx
//    10 xxxxxxxxxx


#include <stdio.h>

int main()
{
    int n, ans = 0;
    char str[101];
    scanf("%d %s", &n, str);
    for(int i = 0; i < n - 2; ++i) {
        if(str[i] == 'x' && str[i + 1] == 'x') {
            int j = i + 2;
            for(; j < n; ++j) {
                if(str[j] == 'x') {
                    ++ans;
                } else {
                    break;
                }
            }
            i = j;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

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

int main(int argc, char *argv[]) {
	int k, l, m, n, b, i, a=0;
	scanf("%d%d%d%d%d", &k, &l, &m, &n, &b);
	for(i=1;i<b+1;i++){
		if ( i%k==0 || i%l==0 || i%m==0 || i%n==0) a++;
	}
	printf("%d",a);
	return 0;
}


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


//
//  796A-codeforces.c
//  Bang Bang Bang
//
//  Created by Mohammad Shamim on 12/4/17.
//  Copyright (c) 2017 Mohammad Shamim. All rights reserved.
//

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

int main()
{
     int i,n,m,k,j=0,x;
     scanf("%d %d %d",&n,&m,&k);
     int h[n],s[n],min=n;
     m--;
     for(i=0;i<n;i++){
         scanf("%d",&h[i]);
         if(h[i]<=k&&h[i]!=0){
             s[j]=i;
             j++;
         }
     }
     for(i=0;i<j;i++){
         if((s[i]-m)<0)
             x=(s[i]-m)*-1;
         else
             x=(s[i]-m);
         if(min>x)
             min=x;
     }
     printf("%d",min*10);
     return 0;
}


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

int main()
{
	int n,pisition,money,i,j;
	int min=9999,output;

	scanf("%d %d %d",&n,&pisition,&money);

	int num[n];

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

	for(i=0;i<n;i++)
	{
		if(num[i]==0||num[i]>money)
		{
			continue;
		}

		output=abs(i+1-pisition)*10;

		if(output<min)
		{
			min=output;
		}
	}

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

	return 0;
}


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


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

char s[51], in[51];

int main()
{
    int i, inLen = 0, j = 0;

    scanf("%s\n%s", s, in);

    inLen = strlen(in);

    for(i=0; i<inLen; i++) if(s[j] == in[i]) j++;

    printf("%d\n", j+1);

    return 0;
}


#include<stdio.h>
#include<string.h>
int main(){
    int j=0;
    char r[50],ins[50];
    scanf("%s",&r);
    scanf("%s",&ins);
    for(int i=0;i<strlen(ins);i++){
    	if(r[j]==ins[i]){
    		j++;
		}
	}
	j++;
	printf("%d",j);
    return 0;
}


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

int main()
{
	int n;
	scanf("%d", &n);
	//int arr[n];
	int sum = 0, a, i;
	int c_1 = 0 , c_2 = 0;
	for(i = 0 ;i < n ;i++ ){
		//scanf("%d", &arr[i]);
		scanf("%d", &a);
		if(a == 100 ) c_1++;
		if(a == 200 ) c_2++;
		sum += a;
	}

	if(n == 1 ){
		if(sum == 200){
			printf("NO\n");
			return 0;
		}
	}

	if(c_1 % 2 == 1){
		printf("NO\n");
		return 0;
	}

	if(c_2 % 2 == 1){
		if(c_1  == 0 ){
			printf("NO\n");
			return 0;
		}
	}

	if(sum % 200 == 0){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}


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

int w[105];
int main()
{
    int n=0,i=0;
    int a=0,b=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&w[i]);
        if(w[i]==100)
             a+=1;
        else
             b+=1;
    }
    if(a&&b){
    if(a%2==0&&b%2!=0)
        printf("YES");
    else if (a%2==0&&b%2==0)
        printf("YES");
    else
        printf("NO");
    }
    else if(a == 0){
        if(b%2==0)
            printf("YES");
        else
            printf("NO");
    }
    else if(b==0){
        if(a%2==0)
            printf("YES");
        else
            printf("NO");
    }

    return 0;
}


#include<stdio.h>
int main()
{
int n,k,l,c,d,p,nl,np,a,b,e,min;
scanf("%d%d%d%d%d%d%d%d",&n,&k,&l,&c,&d,&p,&nl,&np);
a=(k*l)/nl;
b=c*d;
e=p/np;
min=a<b?a<e?a:e:b<e?b:e;
printf("%d",min/n);
}


#include <stdio.h>

int main()
{
   int n, k, l, c, d, p, nl, np;
   int a[100];
   int min = 1001;
   scanf("%d%d%d%d%d%d%d%d", &n, &k, &l, &c, &d, &p, &nl, &np);
   a[0] = k*l/nl;
   a[1] = c*d;
   a[2] = p/np;
   for(int i=0; i<3; i++)
   {
       if(min >= a[i])
       {
           min = a[i];
       }
   }
   printf("%d", min/n);
}


#include <stdio.h>

int main(){

	int r, c, n, min;
	int e, y;
	int x = 0, z = 0;

	scanf("%d %d %d %d", &r, &c, &n, &min);
	int a[r][c];
	for(int i = 0; i < r; i++){
		for(int j = 0; j < c; j++){
			a[i][j] = 0;
		}
	}
	for(int l = 0; l < n; l++){
		scanf("%d %d", &e, &y);
		a[e - 1][y - 1] = 1;
	}
	for(int o = 0; o < r; o++){
		for(int p = 0; p < c; p++)
			for(int q = 0; q <= o; q++)
				for(int k = 0; k <= p; k++){
					x = 0;
		 			for(int i = q; i <= o; i++)
						for(int j = k; j <= p; j++)
							x = x + a[i][j];
					if(x >= min)
						z++;
				}
	}

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


#include <stdio.h>

int main() {
	int i, x1, y1, x2, y2, r, c, n, k, x, y, cnt, rectcnt;
	static int hasviola[10][10];

	scanf("%d%d%d%d", &r, &c, &n, &k);
	for (i = 0; i < n; i++) {
		scanf("%d%d", &x, &y);
		hasviola[x - 1][y - 1] = 1;
	}
	rectcnt = 0;
	for (x1 = 0; x1 < r; x1++)
		for (x2 = x1; x2 < r; x2++)
			for (y1 = 0; y1 < c; y1++)
				for (y2 = y1; y2 < c; y2++) {
					cnt = 0;

					for (x = x1; x <= x2; x++)
						for (y = y1; y <= y2; y++)
							if (hasviola[x][y])
								cnt++;
					if (cnt >= k)
						rectcnt++;
				}

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


#include<stdio.h>
int main()
{
    int s[4],k,j,i,count=0;
    for(i=0;i<4;i++)
    {
        scanf("%d ",&s[i]);
    }
        for(j=0;j<4;j++)
        {
            for(k=j+1;k<4;k++)
            {
                if(s[j]!=s[k])
                {
                    while(s[j]==s[k])
                        count++;
                }
                else
                    {
                    count++;
                break;
                }
            }
        }
        printf("%d",count);
    return 0;
}


#include<stdio.h>
int main()
{
    int c,o,k;
    scanf("%d %d",&c,&o);
     k=o-1;
     //  printf("%d %d %d",k,c,o);
     if(o==1)
     {
         if(c==0)
            printf("Yes");
         else
            printf("No");
     }
     else
    {
        if(c>=k&&c%2==0&&k%2==0&&o!=0)
        printf("Yes");
     else if(c>=k&&c%2!=0&&k%2!=0&&o!=0)
        printf("Yes");
        else
            printf("No");
    }
    return 0;
}


#include<stdio.h>
int main()
{
    long long int x,y;
    scanf("%lld %lld",&x,&y);
    if(y<=1&&x>0)
    {
        printf("NO\n");
    }
    else if(y==0&&x==0)
    {
        printf("NO\n");
    }
    else if(x==0&&y==1)
    {
        printf("YES\n");
    }
    else if(x==0&&y>1)
    {
        printf("NO\n");
    }
    else if(y==1&&x==0)
    {
        printf("YES\n");
    }
    else if(y>1&&x>0)
    {
        if(y>x+1)
        {
            printf("NO\n");
        }
        else if(x%2==1&&y%2==0)
        {
            printf("YES\n");
        }
        else if(x%2==0&&y%2==1)
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}


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


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


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


#include<stdio.h>
int main()
{
    int h1,m1,h2,m2,dm,midm;
    int dh,htm,divh,mod,fh,fm;
    char ch1,ch2;
    scanf("%d",&h1);
    scanf("%c",&ch1);
    scanf("%d",&m1);
    scanf("%d",&h2);
    scanf("%c",&ch2);
    scanf("%d",&m2);
    if(h1==h2)
    {
        dm=m2+m1;
        midm=dm/2;
        if(h1<10)
        {
            printf("0%d:",h1);
        }
        else
        {
            printf("%d:",h1);
        }
        if(midm<10)
        {
            printf("0%d\n",midm);
        }
        else
        {
            printf("%d\n",midm);
        }
    }
    else
    {

        if(m1==m2)
        {
            dh=h2-h1;
            htm=dh*60;
            midm=htm/2;
            divh=midm/60;
            mod=midm%60;
            fh=h1+divh;
            fm=m1+mod;
            if(fm==60)
            {
                fm=0;
                fh=fh+1;
            }
            if(fh<10)
            {
                printf("0%d:",fh);
            }
            else
            {
                printf("%d:",fh);
            }
            if(fm<10)
            {
                printf("0%d\n",fm);
            }
            else
            {
                printf("%d\n",fm);
            }
        }
        else if(m1>m2)
        {
            int c1,c2,tm,dm;
            tm=0;
            c1=h1;
            c2=h2;
            while(c1<c2)
            {
                tm=tm+60-m1;
                tm=tm+m2;
                if(c1<c2-1)
                {
                    dm=m1-m2;
                    tm=tm+dm;
                }
                c1++;
            }
            midm=tm/2;
            divh=midm/60;
            mod=midm%60;
            fh=h1+divh;
            fm=m1+mod;

            if(fm>=60)
            {
                fm=fm-60;
                fh=fh+1;
            }
            if(fh<10)
            {
                printf("0%d:",fh);
            }
            else
            {
                printf("%d:",fh);
            }
            if(fm<10)
            {
                printf("0%d\n",fm);
            }
            else
            {
                printf("%d\n",fm);
            }

        }
        else
        {
            int c1,c2,tm,dm;
            tm=0;
            c1=h1;
            c2=h2;
            while(c1<c2)
            {
                tm=tm+60-m1;
                tm=tm+m2;
                if(c1<c2-1)
                {
                    dm=m2-m1;
                    tm=tm-dm;
                }
                c1++;
            }

            midm=tm/2;
            divh=midm/60;
            mod=midm%60;
            fh=h1+divh;
            fm=m1+mod;

            if(fm>=60)
            {
                fm=fm-60;
                fh=fh+1;
            }
            if(fh<10)
            {
                printf("0%d:",fh);
            }
            else
            {
                printf("%d:",fh);
            }
            if(fm<10)
            {
                printf("0%d\n",fm);
            }
            else
            {
                printf("%d\n",fm);
            }
        }
    }
    return 0;
}


#include<stdio.h>

int main()
{
    int n1,n2,k1,k2,a,b;
    scanf("%d %d %d %d",&n1,&n2,&k1,&k2);
    if(n1<=n2)
        printf("Second\n");
    else
        printf("First\n");
    return 0;
}


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

int main()
{
  int n1 = 0 , n2 = 0 , k1 = 0 , k2  = 0;
  int i = 0 , b = 0;
  scanf("%d%d%d%d",&n1,&n2,&k1,&k2);

   for(i=0;i<100;i++){
        n1--;
    if(n1==0){
         b = 1;
         break;
    }
        n2--;
    if(n2==0){
        b = 0;
        break;
    }
   }
   if(b)
    printf("Second");
   else
    printf("First");

    return 0;
}


#include<stdio.h>
int main()
{
	int n,num=1,i,count=0,flag=0,count1=0,temp;
	scanf("%d",&n);
	while(1)
	{
		if(count==n)
		{
			flag=1;
			break;
		}
		if(count>n)
		{
			break;
		}
		count++;
		count1++;
		num=count1*5;
		temp=num/5;
		while(temp%5==0)
		{
			temp=temp/5;
			count++;
		}
		//printf("%d %d %d\n",num,count1,count);
	}
	if(flag==0)
		printf("0\n");
	else if(flag==1)
	{
		printf("%d\n",(count1+1)*5-num);
		for(i=num;i<(count1+1)*5;i++)
			printf("%d ",i);
		printf("\n");
	}
	return 0;
}


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

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

int main()
{
	int i,j,k,n,a[3],temp,temp1,temp2,temp3,sum,max=-1;
	scanf("%d %d %d %d",&n,a,a+1,a+2);
	qsort(a,3,sizeof(int),cmpfunc);
	temp=n/a[0];
	temp1=n/a[1];
	temp2=n/a[2];
	if(n%a[0]==0)
	{
		printf("%d\n",n/a[0]);
		return 0;
	}
	for(i=temp;i>=0;i--)
	{
		for(j=temp1;j>=0;j--)
		{
			temp3=n-i*a[0]-j*a[1];
			if(temp3%a[2]==0&&temp3>=0)
			{
				sum=i+j+(temp3/a[2]);
				if(sum>max)
				{
					max=sum;
				}
			}
		}
	}
	printf("%d\n",max);
}


#include <stdio.h>

int dp[5000],i,j,k,l,x,ans,m;

int max(int x,int y,int z)
{
    if(x>=y && x>=z)
        return x;
    else if(y>=x && y>=z)
        return y;
    else
        return z;
}
int cut(int x)
{
    int a,b,c;
    if(x==0)
    {
        //printf("if: a:%d b:%d c:%d x:%d\n",a,b,c,x);
        dp[x]=0;
        return 0;
    }
    else if(x<i && x<j && x<k)
    {
        //dp[x]=-100;
        //printf("else if: a:%d b:%d c:%d x:%d\n",a,b,c,x);
        return -100000;
    }
    if(dp[x]!=-1)
        return dp[x];
    else
    {
        a=1+cut(x-i);
        b=1+cut(x-j);
        c=1+cut(x-k);
        dp[x]=max(a,b,c);
        //printf("else: a:%d b:%d c:%d x:%d\n",a,b,c,x);
        return dp[x];
    }
}
int main()
{
    scanf("%d %d %d %d", &l, &i, &j, &k);
    for(m=0; m<5000; m++)
    {
        dp[m]=-1;
    }
    ans=cut(l);
    printf("%d",ans);
    return 0;
}


//http://rextester.com c gcc 5.4.0
main(){
    int a,b;scanf("%d%d",&a,&b);
    if(a<1&b>0){printf("Impossible");}
    else{printf("%d %d",((a)>(b))?(a):(b),b!=0?a+b-1:a);}
}


#include<stdio.h>
int main()
{
    //write your logic here...
    int n,m;

    scanf("%d",&n);

    scanf("%d",&m);
    if (n != 0 || m == 0)
    {
        printf("%d %d\n", (m > n ? m : n), (m != 0 ? n + m - 1 : n));
    }
    else
    {
        printf("Impossible\n");
    }

    return 0;
}


#include <stdio.h>

int main()
{
    int n, i;
    scanf("%d", &n);
    for(i = 31; i >= 0; i--) {
        if(1 << i & n) {
            printf("%d ", i + 1);
        }
    }
    puts("");
    return 0;
}


#include <stdio.h>

int sum_digs(int k)
{
	int s = 0;

	while (k != 0)
	{
		s = s + k % 10;
		k /= 10;
	}

	return s;
}

int perfect_num(int k)
{
	int i = 19;
	int n = 1;

	while ((n < k))
	{
		i += 9;
		if ((sum_digs(i) == 10)) n++;
	}

	return i;
}

int main()
{
	int k;

	scanf("%d", &k);
	printf("%d", perfect_num(k));

	return 0;
}


#include <stdio.h>
int sum(int a){int s=0;
    while(a!=0){
        s+=a%10;
        a/=10;
    }return s;
}
int main(){
    int k;
    scanf("%d",&k);
    int a=1;
    while(k!=0){
        a++;
        if(sum(a)==10)
        k--;
    }
    printf("%d",a);
    return 0;
}


#include<stdio.h>
int main()
{
    long long int n,k,i,t;
    scanf("%I64d%I64d",&n,&k);
    for(i=1;i<=k;i++)
    {
        t=n%10;
        if(t>0)
        {
            n=n-1;
        }
        else
        {
            n=n/10;
        }
    }
    printf("%d",n);
}


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

    int n,k;
    int i;

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

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


#include <stdio.h>

unsigned long long min(unsigned long long a, unsigned long long b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}

unsigned long long max_with_256(k_2, k_3, k_5, k_6) {
  unsigned long long min_32, min_256;
  min_256 = min(min(k_2, k_5), k_6);
  min_32 = min(k_2 - min_256, k_3);
  return 256 * min_256 + 32 * min_32;
}

unsigned long long max_with_32(k_2, k_3, k_5, k_6) {
  unsigned long long min_32, min_256;
  min_32 = min(k_2, k_3);
  min_256 = min(min(k_2 - min_32, k_5), k_6);
  return 256 * min_256 + 32 * min_32;
}

int main() {
  unsigned long long k_2, k_3, k_5, k_6;
  unsigned long long result = 0;

  scanf("%llu", &k_2);
  scanf("%llu", &k_3);
  scanf("%llu", &k_5);
  scanf("%llu", &k_6);

  unsigned long long min_32, min_256;
  min_32 = min(k_2, k_3);
  min_256 = min(min(k_2, k_5), k_6);

  if (max_with_256(k_2, k_3, k_5, k_6) > max_with_32(k_2, k_3, k_5, k_6)) {
    printf("%llu\n", max_with_256(k_2, k_3, k_5, k_6));
  } else {
    printf("%llu\n", max_with_32(k_2, k_3, k_5, k_6));
  }

  return 0;
}


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

main() {
	char s[101], string[102]="a";
	int leng = 0, dist = 0, dist1, dist2;
	scanf("%s", s);
	strcat(string, s);
	while (string[leng] != '\0')
		leng++;

	for (int i = 0; i < leng - 1; i++) {
		char x, y;
		if (string[i] <= string[i + 1]) {
			x = string[i];
			y = string[i + 1];
		}
		else {
			x = string[i + 1];
			y = string[i];
		}
		dist1 = y - x;
		dist2 = (x - 97) + (122 - y) + 1;
		if (dist1 <= dist2)
			dist += dist1;
		else
			dist += dist2;

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


#include<stdio.h>
#include<stdlib.h>
int main(){
        char s[1000];
        scanf("%s", s);
        char cur = 'a';
        int t = 0;
        for(int i = 0;s[i] != '\0';i++){
                t += abs(s[i] - cur) < 26 - abs(s[i]-cur) ? abs(s[i]-cur) : 26 - abs(s[i] - cur);
        cur = s[i];
        }
        printf("%d\n", t);
        return 0;
}


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


#include <stdio.h>

#define MAXN 100002

#define R 0x1
#define B 0x2

unsigned char balls[MAXN+MAXN];

void solve(int prev, int r, int b, int *s1, int *s2) {
	int turn = 0x1;
	int curr;
	if (prev == R) r--;
	else b--;
	*s1 = 0;
	*s2 = 0;
	while (r + b > 0) {
		if (turn == 0) {
			if (prev == R) {
				if (r > 0) {
					r--;
					curr = R;
				}
				else if (b > 0) {
					b--;
					curr = B;
				}
			} else {
				if (b > 0) {
					b--;
					curr = B;
				} else if (r > 0) {
					r--;
					curr = R;
				}
			}
		} else {
			if (prev == R) {
				if (b > 0) {
					b--;
					curr = B;
				} else if (r > 0) {
					r--;
					curr = R;
				}
			} else {
				if (r > 0) {
					r--;
					curr = R;
				} else if (b > 0) {
					b--;
					curr = B;
				}
			}
		}

		if (prev == curr) ++(*s1);
		else ++(*s2);
		turn ^= 0x1;
		prev = curr;
	}
}

int main() {
	int s1, s2;
	int s3, s4;
	int r, b;
	scanf("%d %d", &r, &b);

	solve(R, r, b, &s1, &s2);
	solve(B, r, b, &s3, &s4);
	if (s1 > s3) {
		printf("%d %d\n", s1, s2);
	} else {
		printf("%d %d\n", s3, s4);
	}
	return 0;
}


#include <stdio.h>
#include <string.h>
int bo = 0;
void p(char c)
{
	printf("%c", c); bo = 1;
}

main()
{
	int f, m, s;
	char a[10];
	scanf("%s", a);
	if(strcmp(a, "rock") == 0) f = 1;
	else if(strcmp(a, "paper") == 0) f= 2;
	else if(strcmp(a, "scissors") == 0) f= 3;
	scanf("%s", a);
	if(strcmp(a, "rock") == 0) m = 1;
	else if(strcmp(a, "paper") == 0) m= 2;
	else if(strcmp(a, "scissors") == 0) m= 3;
	scanf("%s", a);
	if(strcmp(a, "rock") == 0) s = 1;
	else if(strcmp(a, "paper") == 0) s= 2;
	else if(strcmp(a, "scissors") == 0) s= 3;
	if(f==m&&m!=s)
		if(s == 1&& f == 3) p('S');
		else if(s==1+f) p('S');
	if(s==m&&f!=s)
		if(f == 1&& s == 3) p('F');
		else if(f==1+s) p('F');
	if(f==s&&m!=s)
		if(m == 1&& s == 3) p('M');
		else if(m==1+s) p('M');
	if(!bo) printf("?\n");
	return 0;
}


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

int main()
{
   char a[10], b[10], c[10];
   scanf("%s %s %s", a, b, c);

    if((strcmp(a, "paper")==0 && strcmp(b, "rock")==0 && strcmp(c, "rock")==0) || (strcmp(a, "rock")==0 && strcmp(b, "scissors")==0 && strcmp(c, "scissors")==0) || (strcmp(a, "scissors")==0 && strcmp(b, "paper")==0 && strcmp(c, "paper")==0))
        printf("F");
    else if((strcmp(b, "paper")==0 && strcmp(a, "rock")==0 && strcmp(c, "rock")==0) || (strcmp(b, "rock")==0 && strcmp(a, "scissors")==0 && strcmp(c, "scissors")==0) || (strcmp(b, "scissors")==0 && strcmp(a, "paper")==0 && strcmp(c, "paper")==0))
        printf("M");
    else if((strcmp(c, "paper")==0 && strcmp(b, "rock")==0 && strcmp(a, "rock")==0) || (strcmp(c, "rock")==0 && strcmp(b, "scissors")==0 && strcmp(a, "scissors")==0) || (strcmp(c, "scissors")==0 && strcmp(b, "paper")==0 && strcmp(a, "paper")==0))
        printf("S");
    else
        printf("?");
}


#include <stdio.h>
int final_time(int h, int m, int pass) {
    return 60*h+m+pass;
}
void conv(int tot, int *h, int *m) {
    *h=tot/60;
    *m=tot%60;
}
void print_time(int h, int m) {
    ((h%24)<10) ? printf("0%d",h%24):printf("%d",h%24);
    printf(":");
    (m<10) ? printf("0%d",m):printf("%d",m);
}
int main() {
    int hour,min,pass,h,m;
    scanf("%d:%d\n%d",&hour,&min,&pass);
    conv(final_time(hour,min,pass),&h,&m);
    print_time(h,m);
    return 0;
}


#include<stdio.h>
int f(int x)
{
    int sum=0;
    while(x>0)
    {
        sum+=x%10;
        x/=10;
    }
    return sum;
}
int main()
{
    int a,b,c;
    int ans[100];
    while(scanf("%d%d%d",&a,&b,&c)!=EOF)
    {
        int i,j,s;
        int t=0;
        for(i=1;i<=81;i++)
        {
            s=1;
            for(j=0;j<a;j++)
                s*=i;
            if(b*s+c>1000000000)break;
            if(f(b*s+c)==i) ans[t++]=b*s+c;
        }
        printf("%d\n",t);
        if(t)
        {
            for(i=0;i<t;i++)
            printf("%d%c",ans[i],i==t-1?'\n':' ');
        }
    }
    return 0;
}


#include <stdio.h>

int s(int x)
{
	int v = 0;
	while (x)
	{
		v += x % 10;
		x /= 10;
	}
	return v;
}

int main()
{
	int sx, a, b, c;
	int sz = 0;
	int ans[100];

	scanf("%d %d %d", &a, &b, &c);
	for (sx = 1; sx <= 81; ++sx)
	{
		long long x = 1;
		int l = a;
		while (l--)
			x *= sx;
		x = b * x + c;
		if (x > 0 && x < 1000000000 && s((int) x) == sx)
			ans[sz++] = (int) x;
	}
	printf("%d\n", sz);
	int i;
	for (i = 0; i < sz; ++i)
		printf("%d ", ans[i]);
	return 0;
}


#include <stdio.h>

int mod(int x)
{
    if (x>=0)
        return x;
    else
        return -x;
}

int main()
{
    long long int x1,x2,y1,y2,x2n,y2n,steps;
    scanf("%I64d %I64d", &x1, &y1);
    scanf("%I64d %I64d", &x2, &y2);

    x2n= mod(x2- x1);
    y2n= mod(y2- y1);
    if (x2n>y2n)
        steps= (y2n) + (x2n-y2n);
    else
        steps= (x2n)+ (y2n-x2n);
    printf("%I64d", steps);
    return 0;
}


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

int main()
{
    int x1,x2,y1,y2,x,y;
    scanf("%d %d",&x1,&y1);
    scanf("%d %d",&x2,&y2);

    x=abs(x1-x2);
    y=abs(y1-y2);

    if(x>=y)
    {
        printf("%d\n",x);
    }
    else
        printf("%d\n",y);

    return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
    char ch[55];
    int n,i,j,k,sum1=0,sum2=0;
    scanf("%d",&n);
    getchar();
    gets(ch);
    //printf("%d",ch[0]);

    for(j=0;j<n/2;j++){
        if(ch[j]=='4'||ch[j]=='7')
           sum1=sum1+(ch[j]-48);
        else{
            printf("NO\n");
            return 0;
        }
    }
    for(k=n/2;k<n;k++){
        if(ch[k]=='4'||ch[k]=='7')
           sum2=sum2+(ch[k]-48);
        else{
            printf("NO\n");
            return 0;
        }
    }

    if(sum1==sum2)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}


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


 main()
{
    long long n;
    scanf("%lld",&n);
    printf("%lld\n",n&1?(n/2)-n:(n/2));
    return 0;
}


#include <stdio.h>

main()
{
	int N;
	int list[1000];
	int i, j;
	int ms, me;
	scanf("%d", &N);
	for (i = 0; i < N; i++)
		scanf("%d", &list[i]);
	list[N] = 0;
	ms = 0;
	for (i = 0; i < N; i++)
		if (list[ms] < list[i])
			ms = i;
	for (j = ms; list[j] == list[ms]; j++)
		me = j;

	while(ms>0)
	{
		if (list[ms] <= list[ms - 1])
		{
			printf("NO\n");
			goto a;
		}
		ms--;
	}
	while (me<N)
	{
		if (list[me] <= list[me + 1])
		{
			printf("NO\n");
			break;
		}
		me++;
	}
	a:
	if (ms == 0 && me == N)
		printf("YES\n");

}


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


#include<stdio.h>
#include<stdlib.h>
void main()
{
long long n,x,ans;

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

long long f[3]={0,1,2};
long long a[3]={1,0,2};
long long b[3]={1,2,0};
long long c[3]={2,1,0};
long long d[3]={2,0,1};
long long e[3]={0,2,1};

if((n-1)%6==0)
	ans=a[x];

else if((n-2)%6==0)
	ans=b[x];

else if((n-3)%6==0)
	ans=c[x];

else if((n-4)%6==0)
	ans=d[x];

else if((n-5)%6==0)
	ans=e[x];

else if((n-6)%6==0)
	ans=f[x];

printf("%lld\n",ans);
exit(0);
}


#include<stdio.h>
int main()
{
    int n,a,b,count=1,max,d,e;
    scanf("%d %d %d",&n,&a,&b);
    max=(a+b)/n;
    while(count&&max)
    {
        d=a/max;
        e=b/max;
        if(d!=0&&e!=0)
        {
            if((d+e)>=n)
            {

                count=0;
                printf("%d",max);
            }
            else{
                max=max-1;
            }
        }

        else
        {
            max=max-1;
        }
    }
}


#include <stdio.h>

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

int main() {
    int N,A,B; scanf("%d %d %d\n", &N, &A, &B);
    int maxv = 0;
    for(int i = 1, in = N ; i < in ; ++i) {
        const int aq = A / i, bq = B / (N-i);
        maxv = max(maxv, min(aq,bq));
    }
    printf("%d\n", maxv);
    return 0;
}


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

void merge(int *arr,int low,int mid,int high){
	int i,j,k,*arr1,*arr2;
	i = j = k = 0;
	arr1 = (int *)malloc(sizeof(int)*(mid-low+1));
	arr2 = (int *)malloc(sizeof(int)*(high-mid));
	while(i++ < mid-low+1) arr1[i-1] = arr[low+i-1];
	while(j++ < high - mid) arr2[j-1] = arr[mid+j];
	i = j = 0;
	while(i < mid-low+1 && j < high - mid)
		if(arr1[i] < arr2[j]) arr[low + k] = arr1[i],i++,k++;
		else arr[low + k] = arr2[j],j++,k++;
	if(i == mid-low+1)
		while(j != high - mid) arr[low + k] = arr2[j] ,j++ ,k++;
	else
		while(i != mid-low+1) arr[low + k] = arr1[i] ,i++ ,k++;
	free(arr1);
	free(arr2);
}

void mergeSort(int *arr,int low,int high){
	if(low == high) return;
	int mid = (low + high )/2;
	mergeSort(arr,low,mid);
	mergeSort(arr,mid+1,high);
	merge(arr,low,mid,high);
}

int main(){
	int n,i = 0,count = 0,j;
	scanf("%d\n",&n);
	int arr[n];
	while(i++ < n){
		scanf("%d",arr+i-1);
	}
	mergeSort(arr,0,n-1);
	for(i = n-1;i > -1; i--){
		for( j = 0;j < i;j++){
			if(arr[i] % arr[j] == 0){
				count++;
				break;
			}
		}
	}
	printf("%d\n",n - count);
	return 0;
}


#include<stdio.h>

int n, a[25],i,j,sumBi=0,sumCh=0,sumBa=0,count=0;

int main()
{
    scanf("%d", &n);
    getchar();
    for(i=0;i<n;i++)
    {
        count++;
        scanf("%d", &a[i]);
        if(count==3)
        {
            sumBa=sumBa+a[i];
            count=0;
        }
        else if(count==2)
        {
            sumBi=sumBi+a[i];
        }
        else
        {
            sumCh=sumCh+a[i];
        }
    }
    if(sumBi>sumCh&&sumBi>sumBa)
    {
        printf("biceps");
    }
    else if(sumBi<sumCh&&sumCh>sumBa)
    {
        printf("chest");
    }
    else
    {
        printf("back");
    }
    return 0;

}


#include <stdio.h>
int main()
{
    unsigned short n, a, i, s[3] = {0};
    scanf("%hu", &n);
    for(i = 0; i < n; i++){
        scanf("%hu", &a);
        s[i % 3] += a;
    }
    if(s[0] >= s[1] && s[0] >= s[2]){ printf("chest"); }
    else if(s[1] >= s[2]){ printf("biceps"); }
    else{ printf("back"); }

    return 0;
}


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

int main(void)
{
    int a,b,hours;
    scanf("%d %d",&a,&b);
    hours=a;
    while(a>=b){
        hours+=a/b;
        a=a/b+a%b;
    }
    printf("%d",hours);
return 0;
}


#include<stdio.h>

int main(){
    int m,n,sum=0,remainder=0,temp;
    scanf("%d%d",&n,&m);
    for(;n>=1;){
        sum = sum + n;
        remainder = remainder + n%m;
        n = n/m;
        if(n<1) {
            temp = remainder%m;
            n = remainder/m;
            remainder = 0;
            remainder = temp+remainder;

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


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

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

int j;
int temp;
for(i=0;i<n;i++)
  for(j=0;j<n-i-1;j++)
  {
    if(a[j+1]<a[j]){
     temp=a[j];
    a[j]=a[j+1];
   a[j+1]=temp;
  }
}
int c=0;
for(i=0;i<n-1;i++)
if(a[i]!=a[i+1] && a[i]!=0)
  c++;

if(c==0)
printf("1");
else
printf("%d",c+1);
}


#include<stdio.h>
int main()
{
    int n,max,min,rem;
    scanf("%d",&n);
    if (n%7==0) { // divisible
    min=(n/7)*2;
    max=min;
    }
    else { // not divisible
    rem=n%7;
    if (rem==6) {
        min=((n/7)*2)+1;
        max=((n/7)*2)+2;
    }
    else if (rem!=6 && rem>=2) {
    min=(n/7)*2;
    max=min+2;
    }
    else{ // rem==1
            min=(n/7)*2;
    max=min+1;
   }
    }
    printf("%d %d\n",min,max);
    return 0;
}


#include <stdio.h>

int main()
{
    long y;
    scanf("%ld", &y);

    long max, min;

    switch (y)
    {
        case 0: min = 0, max = 0; break;
        case 1: min = 0, max = 1; break;
        case 2: min = 0, max = 2; break;
        case 3: min = 0, max = 2; break;
        case 4: min = 0, max = 2; break;
        case 5: min = 0, max = 2; break;
        case 6: min = 1, max = 2; break;
        default: min = 2*(y/7) + (y%7 == 6);
            max = 2*(y/7) + (y%7 > 2 ? 2 : y%7); break;
    }

    printf("%ld %ld\n", min, max);

    return 0;
}


#include<stdio.h>
int main(){
    long long int a,b,c,d,x,y,z;
    scanf("%lld %lld %lld",&x,&y,&z);
    scanf("%lld %lld %lld",&a,&b,&c);

    if(a >= x){
        a = a-x;
        d = a + b;
        if(d>= y){
            d = d- y ;

            if(d + c >= z){
                printf("YES");
            }
            else{
                printf("NO");
            }

    }
    else{
        printf("NO");
    }
}
    else{
        printf("NO");
    }

}


#include<stdio.h>
int main()
{
    int a,b,c,x,y,z;
    scanf("%d",&x);
    scanf("%d",&y);
    scanf("%d",&z);
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
 /*Dhur beeta , egula hoilo beta?? ei problem 3 bar submit korlam ..*/

    if(a>=x&&b+a-x>=y&&a+b+c-x-y>=z)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


// Cola

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

#define ll long long

int count[20000];

void deal(int n, int a, int b, int c)
{
    int i, j;
    ll ans = 0;
    memset(count, 0, sizeof(count));
    for (i = 0; i <= b; i++)
    {
/*      if (i > n)
        {
            break;
        }*/
        for (j = 0; j <= c; j++)
        {
/*          if (i + 2 * j > n)
            {
                break;
            }*/
            count[i + 2 * j]++;
        }
    }
    for (i = 0; i <= a; i += 2)
    {
        if (n - i / 2 < 0)
        {
            break;
        }
        ans += count[n - i / 2];
    }
    printf("%lld\n", ans);
}

int main(int argc, char **argv)
{
    int a, b, c, n;
    while (scanf("%d%d%d%d", &n, &a, &b, &c) == 4)
    {
        deal(n, a, b, c);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main(){
    int len,n[100],i;
    char s[100];
    scanf("%s", &s);
    len=strlen(s);
    for(i=0;i<len;i++){
        n[i]=s[i]-'0';
        if(n[i]>4)n[i]=9-n[i];
    }

    if(n[0]==0)n[0]=9;
    for(i=0;i<len;i++){
        printf("%d",n[i]);
    }
    printf("\n\n");
    return 0;
}


#include<stdio.h>
#include<string.h>
main()
{
	int l, i;
	char ss[21];
	scanf("%s", ss);
	l = strlen(ss);
	for (i = 0; i < l; i++)
		if (ss[i] > 52)
			ss[i] = 57 - ss[i] + 48;
	if (ss[0] == 48)
		ss[0] = 57;
	printf("%s", ss);
	printf("\n");
}


#include<stdio.h>
#include<string.h>
int main()
{
          int A,B,i,j=0,k;
          char str[1002];
          scanf("%d",&k);
          scanf("%s",str);
          for(i=0;i<k;i++)
          {
                if(str[i]==str[i+1])
                {
                          j=j+1;
                }
                else if(str[i]!=str[i+1])
                {
                          j=j+1;
                          i++;
                }
          }
          printf("%d\n",j);
          return 0;

}


#include <stdio.h>

int main()
{
    int n, i, move = 1;

    scanf("%d", &n);

    char a[n + 1];

    scanf("%s", a);

    for(i = 1; i < n; i++) {
        if (a[i] != a[i - 1] && a[i - 1] != 'D') a[i] = 'D';
        else move++;
    }
    printf("%d\n", move);

    return 0;
}


#include <stdio.h>

int main()
{
	int m,d;
	scanf("%d %d",&m,&d);
	if (m>0 && m<13 )
	{
		switch(m)
		{
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12:
				if (d<6 )
					printf("5");
				else
					printf("6");
				break;
			case 2:
				if (d==1)
					printf("4");
				else
					printf("5");
				break;
			default:
				if (d<7 )
					printf("5");
				else
					printf("6");
				break;

		}
	}
	//printf("mot 2 ba %d   %d",m,d);

	return 0;
}


#include<stdio.h>

int main(void)
{
    char s[110];
    scanf("%s", s);
    int p=0;
    int q=0;
    int l=strlen(s);
    int i;
    for(i=0; i<l; ++i){
        s[i]=='o'? ++p:++q;
    }
    if(p==0){
        printf("YES");
    }
    else if(q%p==0){
        printf("YES");
    }
    else{
        printf("NO");
    }
}


#include<stdio.h>
int main()
{
    char s[100];
    int o=0,e=0,i;
    scanf(" %s",s);

    for(i = 0; s[i]!='\0'; i++)
    {
        if(s[i]=='o')
            o++;
        else if(s[i]=='-')
            e++;
    }
    if(o==0)
        printf("YES\n");

    else if(e%o==0)
        printf("YES\n");

    else if(e%o!=0)
        printf("NO\n");

    return 0;
}


#include<stdio.h>
int main(){
	int a, b, c, d, ab, ac, ad, bc, bd, cd;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	ab=a+b;
	ac=a+c;
	ad=a+d;
	bc=b+c;
	bd=b+d;
	cd=c+d;
	if((ab>c&&ac>b&&bc>a)||(bc>d&&bd>c&&cd>b)||(bd>a&&ab>d&&ad>b)||(ac>d&&ad>c&&cd>a)){
		printf("TRIANGLE");
		return 0;
	}
	else if((ab==c||ac==b||bc==a)||(bc==d||bd==c||cd==b)||(bd==a||ab==d||ad==b)||(ac==d||ad==c||cd==a)){
		printf("SEGMENT");
		return 0;
	}
	else
		printf("IMPOSSIBLE");
	return 0;
}


#include<stdio.h>
//成功了，感觉这还是最优策略问题
#define N 10
char grid[N+2][N+2];
int x[N*N];
int y[N*N];
int wolf;

int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	int i,j;
	getchar();
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			grid[i][j]=getchar();
		}
		getchar();
	}
	//四周都是狼，我可以避免一些边界检查
	for(j=0;j<=m+1;j++){
		grid[0][j]='W';
		grid[n+1][j]='W';
	}
	for(i=1;i<=n;i++){
		grid[i][0]='W';
		grid[i][m+1]='W';
	}
	/*
	for(i=0;i<=n+1;i++){
		for(j=0;j<=m+1;j++){
			printf("%c",grid[i][j]);
		}
		printf("\n");
	}
	*/

	wolf=0;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			if(grid[i][j]=='W'){
				x[wolf]=i;
				y[wolf]=j;
				wolf++;
			}
		}
	}
	int total=wolf;
	for(i=0;i<wolf;i++){
		int wx=x[i];
		int wy=y[i];
		//再吃右边的
		if(grid[wx][wy+1]=='P'){
			grid[wx][wy+1]='W';
		//先吃上边的
		}else if(grid[wx-1][wy]=='P'){
			grid[wx-1][wy]='W';
		//再吃左边的
		}else if(grid[wx][wy-1]=='P'){
			grid[wx][wy-1]='W';
			//由于我们是一层一层地吃，
			//所以，我们最后一个吃下面的！
			//可以先吃下面的，在吃右边的！
		}else if(grid[wx+1][wy]=='P'){
			grid[wx+1][wy]='W';
		}else{
			//这条狼没有吃到猪
			total--;
		}

	}
	//剩下的可以吃到猪的狼的个数
	printf("%d\n",total);
	return 0;
}


#include<stdio.h>
#include<string.h>
#define baccha hobe na baccha hobe na baccha hobe na - Shajib Vai :D
int main()
{
    long long n,i,j,x,y,z;
    char c,a[10] = "fedabc";
    scanf("%lld%c",&n,&c);
    for(i=0; i<6; i++)
    {
        if(c==a[i])
        {
            j = i+1;
            break;
        }
    }
    if(n%4==0 || (n+1)%4==0)
    {
        x = n/2;
        z = (n-x)-2;
    }
    else
    {
        x = (n/2)+1;
        z = (n-x);
    }
    y = (x-1)*7+j+z;
    printf("%lld\n",y);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,c,d[1000],i,dif,min=0,a,b,pro,no=0;
    scanf("%d %d",&n,&c);
    for(i=0;i<n;i++)
        scanf("%d",&d[i]);
    for(i=0;i<n-1;i++){
        if(d[i]>d[i+1]){
            dif=d[i]-d[i+1];
            if(dif>min){
                a=d[i];
                b=d[i+1];
                min=dif;
            }
         }
         else
            no++;
    }
    if(no==(n-1)){
        a=c;
        b=0;
    }

    pro=a-b-c;
    if(pro<0)
        pro=0;
    printf("%d\n",pro);

    return 0;
}


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


#include <stdio.h>

int xpo[4], ypo[4];
int xd[] = {1, 0, 0, -1};
int yd[] = {0, 1, -1, 0};

int isri(int n)
{
  int i, j, k;
  int q, w, e;
  i = (n + 1) % 3;
  j = (n + 2) % 3;
  q = (xpo[i] - xpo[n]) * (xpo[j] - xpo[n]) + (ypo[i] - ypo[n]) * (ypo[j] - ypo[n]);
  w = xpo[i] * (ypo[j] - ypo[n]) - xpo[j] * (ypo[i] - ypo[n]) + xpo[n] * (ypo[i] - ypo[j]);
  if(q == 0 && w != 0)
    return 1;
  return 0;
}

int main(void)
{
  int i, j, k, l, m;
  for(i = 0; i < 3; i++)
    scanf("%d%d", xpo + i, ypo + i);
  for(i = 0; i < 3; i++)
    if(isri(i)){
      puts("RIGHT");
      return 0;
    }
  for(i = 0; i < 3; i++){
    j = xpo[i];
    k = ypo[i];
    for(l = 0; l < 4; l++){
      xpo[i] = j + xd[l];
      ypo[i] = k + yd[l];
      for(m = 0; m < 3; m++)
	if(isri(m)){
	  puts("ALMOST");
	  return 0;
	}
    }
    xpo[i] = j;
    ypo[i] = k;
  }
  puts("NEITHER");
  return 0;
}
/*
A. Triangle
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

At a geometry lesson Bob learnt that a triangle is called right-angled if it is nondegenerate and one of its angles is right. Bob decided to draw such a triangle immediately: on a sheet of paper he drew three points with integer coordinates, and joined them with segments of straight lines, then he showed the triangle to Peter. Peter said that Bob's triangle is not right-angled, but is almost right-angled: the triangle itself is not right-angled, but it is possible to move one of the points exactly by distance 1 so, that all the coordinates remain integer, and the triangle become right-angled. Bob asks you to help him and find out if Peter tricks him. By the given coordinates of the triangle you should find out if it is right-angled, almost right-angled, or neither of these.
Input

The first input line contains 6 space-separated integers x1, y1, x2, y2, x3, y3 — coordinates of the triangle's vertices. All the coordinates are integer and don't exceed 100 in absolute value. It's guaranteed that the triangle is nondegenerate, i.e. its total area is not zero.
Output

If the given triangle is right-angled, output RIGHT, if it is almost right-angled, output ALMOST, and if it is neither of these, output NEITHER.
Sample test(s)
Input

0 0 2 0 0 1

Output

RIGHT

Input

2 3 4 5 6 6

Output

NEITHER

Input

-1 0 2 0 0 1

Output

ALMOST
*/


#include<stdio.h>

int main()
{
    int a[10], i, j, k, sum1=0, sum2=0, total = 0, u = 0;
    //printf("Enter six integers : ");
    for(i = 0; i < 6; i++)
    {
        scanf("%d", &a[i]);
        total += a[i];
    }
    sum1 = 0;
    sum2 = 0;
    u=0;
    for(i = 0; i < 6; i++)
    {
        for(j = i+1; j < 6; j++)
        {
            for(k = j+1; k < 6  ; k++)
            {
                sum1 = a[i]+a[j]+a[k];
                sum2 = total - sum1;

        if(sum1 == sum2)
        {
            u++;
        }

    }
}
    }
if(u>0)
{
    printf("YES\n");
}
else{printf("NO\n");}

return 0;}


#include<stdio.h>
int main(){
	int i,j,k,sum=0,flag=0;
	int arr[6];
	for(i=0;i<6;i++){
		scanf("%d",&arr[i]);
		sum+=arr[i];
	}
	for(i=0;i<5;i++){
		for(j=i+1;j<6;j++){
			for(k=j+1;k<7;k++){
				if((arr[i]+arr[j]+arr[k])<<1 == sum){
					flag=1;
					break;
				}
			}
		}
	}
	if(flag)printf("YES\n");
	else printf("NO\n");
	return 0;
}


#include <stdio.h>

int main(void)
{
	unsigned long long int ar[1000000],n;
	int i,num=0;
	ar[1]=5;
	ar[2]=7;
	for(i=3;i<1000000;i++)
		{
		ar[i]=ar[i-1]+3*i-1;
		//printf("%llu ",ar[i]);
		}
	scanf("%llu",&n);
	if(n==2)
		{
		printf("1");
		return 0;
		}
	i=1;
	while(ar[i]<=n)
		{
			if((n-ar[i])%3==0)
				num++;
			i++;
		}
	printf("%d",num);
	return 0;
}


#include<stdio.h>
int main()
{
    long long int n,i,ans=0;
    scanf("%lld",&n);
    for(i=1;(3*i*(i+1)/2-i)<=n;i++)
    {
        if((n+i)%3==0)
        ans++;
    }
    printf("%d\n",ans);
    return 0;
}


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


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


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


#include<stdio.h>

int main()
{
    int a;

    scanf("%I64d",&a);

    if(a%2==0) printf("Mahmoud\n");
    else printf("Ehab\n");
}


main(){int x;scanf("%d",&x),printf("%d",2-x*x);}
//nz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioinz ak ioi


#include<stdio.h>
int main()
{
int a;
scanf("%d",&a);
printf("%d",2-(a*a));
return 0;
}


#define N 102
#include<stdio.h>
#include<string.h>
//10^100应该是101位整数，所以要用102位的字符串来保存
int main() {
	char a[N];
	char b[N];
	scanf("%s",a);
	scanf("%s",b);
	int na=strlen(a);
	int nb=strlen(b);
	if(na==nb){
		int same=1;
		int i;
		for(i=0;i<na;i++){
			if(a[i]!=b[i]){
				same=0;
				break;
			}
		}
		if(same){
			printf("%s\n",a);
		}else{
			printf("1\n");
		}
	}else{
		printf("1\n");
	}
	return 0;
}


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

int main()
{
    char a[1005], b[1005];
    scanf("%s %s", &a, &b);
    printf("%s\n", (strcmp(a, b))?"1":b);
    return 0;
}


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


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


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

int main()
{
        int c1,c2,i;
        char s[55];

        scanf("%s",s);
        c1=c2=0;
        for(i=0;i<strlen(s);i++)
        {
                if(s[i]=='4')
                        c1++;
                else if(s[i]=='7')
                        c2++;
        }

        if(c1==c2 && c1==0)
        {
                printf("-1\n");
        }
        else if(c1>=c2)
        {
                printf("4\n");
        }
        else
        {
                printf("7\n");
        }

        return 0;
}


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

int main()
{
        int i, cs, cf;
        char s[51];
        scanf("%s",s);
        cs=cf=0;
        for(i=0;i<strlen(s);i++)
        {
                if(s[i] == '4')
                cf++;
                if(s[i] == '7')
                cs++;
        }
        if((cs == 0) && (cf == 0)) { printf("-1"); return 0;}
        if(cs > cf) printf("7");
        else printf("4");
        return 0;
}


#include<stdio.h>

int main()
{
 long long n;
 long long k;
 long long out;
 long long i;
 long long fives=0;
 long long twos=0;
 long long temp;
 long long multwo;
 long long mulfive;

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

 temp=n;
 for(i=0;i<k;i++)
 {
  if((temp%5)==0)
  {
   temp=temp/5;
   fives++;
  }else{
   break;
  }
 }

 temp=n;
 for(i=0;i<k;i++)
 {
  if((temp%2)==0)
  {
   temp=temp/2;
   twos++;
  }else{
   break;
  }
 }

 multwo=k-twos;
 mulfive=k-fives;
 out=n;
 if(multwo>0)
 {
  for(i=0;i<multwo;i++) out=out*2;
 }

 if(mulfive>0)
 {
  for(i=0;i<mulfive;i++) out=out*5;
 }

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

 return 0;
}


#include<stdio.h>
typedef long long ll;
int main()
{
	ll n;
	scanf("%lld",&n);
	printf("%lld\n",(n-2)*(n-2));
	return 0;
}


#include<stdio.h>
int main()
{
    long long int n,i;
    scanf("%lld",&n);
    i=n-2;
    printf("%lld",i*i);
}


// https://codeforces.com/contest/59/problem/A

#include <stdint.h>
#include <stdio.h>

#define IN_RANGE(v, s, e)   ( (s) <= (v) && (v) <= (e) )

#define IS_LOWER(c)         IN_RANGE(c, 'a', 'z')
#define IS_UPPER(c)         IN_RANGE(c, 'A', 'Z')

#define IS_ALPHA(c)         ( IS_UPPER(c) || IS_LOWER(c) )
#define IS_DIGIT(c)         IN_RANGE(c, '0', '9')
#define IS_ALNUM(c)         ( IS_ALPHA(c) || IS_DIGIT(c) )

#define TO_LOWER(c)         (IS_UPPER(c)) ? c += 32 : c ;
#define TO_UPPER(c)         (IS_LOWER(c)) ? c -= 32 : c ;

#define MAX_LINE            100u

uint8_t CountUpperCase(uint8_t * str, uint8_t str_len);
void ToUpperCase(uint8_t * str, uint8_t str_len);
void ToLowerCase(uint8_t * str, uint8_t str_len);

int main(void)
{
  uint8_t word[MAX_LINE] = {0};
  uint8_t str_len = 0u;
  uint8_t upper_case_count = 0u;

  scanf("%s", word);

  while(word[str_len]) str_len++;

  upper_case_count = CountUpperCase(word, str_len);

  if(upper_case_count > (str_len/2))
  {
    ToUpperCase(word, str_len);
  }
  else
  {
    ToLowerCase(word, str_len);
  } /*  end if  */

	printf("%s\n", word);

	return 0;
}

uint8_t CountUpperCase(uint8_t * str, uint8_t str_len)
{
  uint8_t upper_count = 0u;

  for(uint8_t i = 0u; i < str_len; i++)
  {
    if(IS_UPPER(str[i]))
    {
      upper_count++;
    } /*  end if    */

  } /*  end for   */

  return upper_count;
}

void ToUpperCase(uint8_t * str, uint8_t str_len)
{
  for(uint8_t i = 0u; i < str_len; i++)
  {
    if(IS_LOWER(str[i]))
    {
      str[i] = TO_UPPER(str[i]);
    } /*  end if  */
  } /*  end for   */
}

void ToLowerCase(uint8_t * str, uint8_t str_len)
{
  for(uint8_t i = 0u; i < str_len; i++)
  {
    if(IS_UPPER(str[i]))
    {
      str[i] = TO_LOWER(str[i]);
    } /*  end if  */
  } /*  end for   */
}


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

int main ()
{
    int len, i, j, upp = 0, low = 0;
    char str[104];

    scanf("%s", str);

    len = strlen(str);

    for(i = 0; i < len; i++)
    {
        if(str[i] >= 'A' && str[i] <= 'Z')
            upp++;
        else
            low++;
    }

    if(upp > low)
    {
        for(j = 0; j < len; j++)
        {
            if(str[j] >= 'a' && str[j] <= 'z')
                str[j] = str[j] - 32;
            printf("%c", str[j]);
        }
    }

    else{
        for(j = 0; j < len; j++)
        {
            if(str[j] >= 'A' && str[j] <= 'Z')
                str[j] = str[j] + 32;
            printf("%c", str[j]);
        }
    }

    return 0;
}


#include <stdio.h>
int main(){
    long long n,m,a,l,b;
    scanf("%lld%lld%lld",&n,&m,&a);
    if(n%a == 0)
        l = n/a;
    else
        l = n/a + 1;
    if(m%a == 0)
        b = m/a;
    else
        b = m/a + 1;
    printf("%lld",l*b);
    return 0;
}


//Theatre square problem
#include<stdio.h>
#include<math.h>
int main(){
unsigned long long int n,m,a,tile1,tile2,total;
scanf("%lld", &n);//one side of the theatre square
scanf("%lld", &m);//other side of the theatre square
scanf("%lld", &a);//side of the square tile
if(((double)n/a)-(n/a)>0)
{
tile1=(n/a)+1;
}
else
    tile1=(n/a);
if(((double)m/a)-(m/a)>0)
{
tile2=(m/a)+1;
}
else
    tile2=(m/a);
total=tile1*tile2;
printf("%lld", total);

return 0;

}


#include<stdio.h>
#include<math.h>
//#include<stdio.h>
int main()
{
    int x1,y1;
    scanf("%d%d",&x1,&y1);
    int sum=abs(x1)+abs(y1);
    //printf("%d\n",sum);
    if(x1>0&&y1>0) printf("0 %d %d 0\n",sum,sum);
    if(x1>0&&y1<0) printf("0 -%d %d 0\n",sum,sum);
    if(x1<0&&y1>0)printf("-%d 0 0 %d\n",sum,sum);
    if(x1<0&&y1<0)printf("-%d 0 0 -%d\n",sum,sum);
    //system("pause");
    return 0;
}


#include<stdio.h>
int main()
{
	long long int t,s,x;
	scanf("%lld %lld %lld",&t,&s,&x);
	if(x>=t)
	{
	if((x-t)%s==0||((x-t-1)%s==0&&(x-t-1!=0)))
	{
		printf("YES\n");
	}
		else
	printf("NO\n");
	}
	else
	printf("NO\n");

	return 0;
}


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

int main()
{

  int t,s,x ;
  scanf("%d%d%d",&t,&s,&x);
int d = x - t;
 if (x == t + 1) printf("NO");

	else if (d < 0) printf("NO");

	 else if (d % s == 0) printf("YES");
	 else if (d % s == 1) printf("YES");

	else printf("NO");

}


#include<stdio.h>
int GCD(int a, int b){
	int r;
	do{
		r = a%b;
		a = b;
		b = r;
	} while (r != 0);
	return a;
}
int main(){
	int n;
	while (scanf("%d", &n) == 1){
		int M[100];
		for (int i = 0; i < n; i++)
			scanf("%d", M + i);
		for (int i = 0; i < n; i++){
			for (int j = i + 1; j < n; j++){
				M[i] = M[j] = GCD(M[i], M[j]);
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++)
			ans += M[i];
		printf("%d\n", ans);
	}
	return 0;
}


#include <stdio.h>
int g ( int x, int y )
{
  if ( x==0 ) return y;
  return g( y%x, x );
}
int main (){
    int n,i,c;
    scanf("%d",&n);
    int a[n+1];
    for(i=0;i<n;i++)
    {scanf("%d",&a[i]);
        if(i==0)
        c=a[i];
       if(i>0)
       c=g(c,a[i]);
        }
        printf("%d\n",n*c);
return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int Comp(const void*a,const void*b)
{
return *(int*)b-*(int*)a;
}
int gcd(int a,int b)
{
	int t;
	while(b)
	{
		a%=b;
		if(a<b)
		{
			t=a;
			a=b;
			b=t;
		}
	}
	return a;
}
int a[10000],b[10000];
int main()
{
	int n,m,a,b;
	int x=0,y=0,k=1,j,i=0,max=0,min=0,sum=0,sum1=0;
	scanf("%d %d %d %d",&n,&m,&a,&b);
	if(m<=n)
	{
		if(b/m>=a)
		{
			printf("%d\n",a*n);
		}
		else
		{
			x=n/m;
			y=n-x*m;
			if(b<a*y)
			{
				sum=(x+1)*b;
			}
			else
			{
				sum=x*b+a*y;
			}
			printf("%d",sum);
		}
	}
	else
	{
		if(b<=a*n)
		{
			printf("%d\n",b);
		}
		else
		{
			printf("%d",a*n);
		}
	}
	return 0;
}


#include<stdio.h>
int main()
{
    int n,m,a,b,s,t;
    float p;
    scanf("%d %d %d %d",&n,&m,&a,&b);
    p=(b/m)*1.0;
     s=n/m;
     t=n%m;
     if(n>m){
    if(t!=0){
    if(p==a || p>a){
        printf("%d",a*n);
    }
    else if(p<a){
        if(b>a){
        printf("%d",s*b+t*a);
        }
        else printf("%d",s*b+b);
    }
    }
    else {
        if(p==a || p>a){
        printf("%d",a*n);
    }
    else if(p<a) {
        printf("%d",s*b);
    }
    }
     }
     else {
         if((a*n)<=b){
             printf("%d",a*n);
         }
         else printf("%d",b);
    }
    return 0;
}