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

long long a ,b,c,mini,nr;

int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&c);
if(a>3 || b>2 || c>2)
{

mini=a/3;
if(b/2 <mini)
    mini=b/2;
if(c/2 <mini)
    mini=c/2;
}

a=a-3*mini;
b=b-2*mini;
c=c-2*mini;
nr=mini*7;
if(a>3)
    a=3;
if(b>2)
    b=2;
if(c>2)
    c=2;

if(a==b && b==c)
    nr=nr+a+b+c;
if(a>b && a>c)
{
    if(b==0 && c==0)
        nr=nr+2;
        else
    if(b==c)
        nr=nr+a+b+c;
    else
    {
        if(b!=0 && c!=0)
            nr=nr+6;
        else
        {
            if(a==2)
                if(c==1)
                  nr=nr+3;
                else
                    if(b==1)
                        nr=nr+3;
            if(a==3)
            {
                if(b>0)
                    nr=nr+b+2;
                if(c>0)
                    nr=nr+c+1;
                }
        }
    }

}
else
if(b>a || c>a)
{

    if(a>0)
    {

        if(b==0 || c==0)
        {

        if(b==0)
            nr=nr+3;
        if(c==0)
            nr=nr+2;

        }

    if(b!=0 && c!=0 )
    {

        if(c==2)
            nr=nr+a+b+c;
        else
            nr=nr+3;

    }
    }
    else
        if(a==0 && c>0 && b>0)
            nr=nr+2;
    else

        nr++;

}
else

    if(a==b || a==c )
        if(b!=c)
        if(b==0 )
            nr=nr+c+1;
        else
            nr=nr+a+b+c;

printf("%I64d",nr);

    return 0;
}

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

int main(){

    long long  totald,min,a,b,c,ca,cb,cc;
    scanf("%lld%lld%lld",&a,&b,&c);
    ca=a/3;a=a%3;
    cb=b/2;b=b%2;
    cc=c/2;c=c%2;
    min=ca<cb?(ca<cc?ca:cc):(cb<cc?cb:cc);
    ca-=min;
    cb-=min;
    cc-=min;
    totald=min*7;
    a+=ca*3;
    b+=cb*2;
    c+=cc*2;

     //printf("%lld %lld %lld %lld\n",a,b,c,totald);

    long long count,max=-1,tmpa,tmpb,tmpc,arr[14];
    for(int i=0;i<14; i++){
        tmpa=a;
        tmpb=b;
        tmpc=c;
        memset(arr,0,sizeof(arr));
        for(int j=i;j<14; j++){
            if((j%7==0 || j%7==3) && tmpb){
                arr[j]=1;
                tmpb--;
            }
            else if((j%7==1 || j%7==2 || j%7== 5 )&& tmpa){
                arr[j]=2;
                tmpa--;
            }
            else if((j%7==4 || j%7==6 )&& tmpc){
                arr[j]=3;
                tmpc--;
            }
        }
        count=0;
        for(int k=i;k<14; k++){
            if(arr[k]==0)break;
          //printf("%d ",arr[k] );
            count++;
        }
      //puts("");
        if(count>max){
            max=count;
        }
    }
    printf("%lld\n",totald+max);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int min(int x,int y,int z)
{
	if(x<=y && x<=z)
		return x;
	else if(y<=x && y<=z)
		return y;
	else if(z<=x && z<=y)
		return z;
}
/*int max(int x,int y,int z)
{
	if(x>=y && x>=z)
		return x;
	else if(y>=z && y>=x)
		return y;
	else if(z>=x && z>=y)
		return z;
}*/
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int x = a/3;
	int y = b/2;
	int z = c/2;
	int k = min(x,y,z);
	int a1 = a - 3*k;
	int b1 = b - 2*k;
	int c1 = c - 2*k;
	long long int d1 = 7*k;
	int m =0;
	int arr[7] = {0,1,2,0,2,1,0};
	for(int i = 0;i<7;i++)
	{	int max = 0;
		int temp[3];
		temp[0]=a1;temp[1]=b1;temp[2]=c1;
		for(int j =i;j<(i+7);j++)
		{
			if(temp[arr[j%7]]==0)
				break;
			temp[arr[j%7]]--;
			max++;
		}
	//	printf("max = %d\n",max);
		if(m<max)
			m = max;
	}
	d1 = d1+m;
	printf("%lld\n",d1);
	return 0;
}

#include<stdio.h>
#include<math.h>
int main(){
	long long ans[10]={0},max,flag,count[4]={0},a,b,c,i,st,a1,a2,a3;
	scanf("%lld%lld%lld",&a,&b,&c);
	count[1]=a;
	count[2]=b;
	count[3]=c;
        for(i=1;i<=7;i++)
	{

		flag=i;
		count[1]=a;
		count[2]=b;
		count[3]=c;
		if(count[1]>=3 && count[2]>=2 && count[3]>=2)
		{
			a1=count[1]/3;
			a2=count[2]/2;
			a3=count[3]/2;
			st=fmin(a1,fmin(a2,a3));
			count[1]-=st*3;
			count[2]-=st*2;
			count[3]-=st*2;
			ans[i]+=st*7;
		}

		while(1)
		{
			//start monday
			if(flag==1)
			{
				if(count[1]==0)
					break;
				count[1]--;
				ans[i]++;
				flag=2;
			}
			if(flag==2)
			{
				if(count[2]==0)
					break;
				count[2]--;
				ans[i]++;
				flag=3;
			}
			 if(flag==3)
                        {
                                if(count[3]==0)
                                        break;
                                count[3]--;
                                ans[i]++;
                                flag=4;
                        }
			  if(flag==4)
                        {
                                if(count[1]==0)
                                        break;
                                count[1]--;
                                ans[i]++;
                                flag=5;
                        }
			   if(flag==5)
                        {
                                if(count[3]==0)
                                        break;
                                count[3]--;
                                ans[i]++;
                                flag=6;
                        }
			    if(flag==6)
                        {
                                if(count[2]==0)
                                        break;
                                count[2]--;
                                ans[i]++;
                                flag=7;
                        }
			     if(flag==7)
                        {

                                if(count[1]==0)
                                        break;
                                count[1]--;
                                ans[i]++;
				flag=1;
                        }
		}
	}

	max=0;
	for(i=1;i<=7;i++)
	{
	//	printf("%lld\n",ans[i]);
		if(ans[i]>=max)
			max=ans[i];
	}
	printf("%lld\n",max);
	return 0;
}

#include <stdio.h>

int main(){
    int a, b, c, sum = 0, r = 0;
    scanf("%d %d %d", &a, &b, &c);
    while(a >= 3 && b >= 2 && c >= 2){
        a -= 3;
        b -= 2;
        c -= 2;
        sum += 7;
    }
    int next, e, ccc, ee, aa, bb, cc;
    for(int i = 0; i < 7; i++){
        next = 1; e = i; ccc = 0; aa = a; bb = b; cc = c;
        while(next){
            ee = e%7;
            if(ee == 0 || ee == 3 || ee == 6){
                if(aa == 0){
                    next = 0;
                } else {
                    aa--;
                }
            } else if(ee == 1 || ee == 5){
                if(bb == 0){
                    next = 0;
                } else {
                    bb--;
                }
            } else {
                if(cc == 0){
                    next = 0;
                } else {
                    cc--;
                }
            }
            if(next){
                ccc++;
                e++;
            }
        }
        if(ccc > r){
            r = ccc;
        }
    }
    printf("%d", sum+r);
    return 0;
}

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

typedef long long int LL;

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

int main(){
	// 1, 4, 7: fish
	// 2, 6: 	rabbit
	// 3, 5: 	chicken

	int f, r, c;
	scanf("%d%d%d", &f, &r, &c);

	int base = min(min(f/3, r/2), c/2);	/*base weeks*/

	f -= 3 * base;
	r -= 2 * base;
	c -= 2 * base;

	LL day = (LL)base * 7;
	LL max = day;

	LL tmp;

	int ff = f, rr = r, cc = c;

	for(int i = 1; i <= 7; ++i){
		// start at day i
		tmp = day;
		ff = f; rr = r; cc = c;
		for(int j = 0, done = 0; !done; ++j){
			switch( (i+j) % 7 ){
				case 1: case 4: case 0:	/* fish */
					if(ff > 0){
						ff--;
						tmp++;
					}else{
						done = 1;
					}
					break;
				case 2: case 6:			/* rabbit */
					if(rr > 0){
						rr--;
						tmp++;
					}else{
						done = 1;
					}
					break;
				default:				/* chicken */
					if(cc > 0){
						cc--;
						tmp++;
					}else{
						done = 1;
					}
					break;
			}
		}
		if(tmp > max) max = tmp;
//		printf("i = %d, count = %I64d\n", i, tmp);
	}

	printf("%I64d\n", max);

	return 0;
}

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

typedef unsigned long long opo;

#define S scanf
#define P printf
#define M malloc
#define SI sizeof

int cmp(const void *a, const void *b)
{
	int *c;
	int *d;
	c = (int*)a;
	d = (int*)b;
	if (*c > *d)
		return (1);
	if (*c == *d)
		return (0);
	return (-1);
}

int main()
{
	int a,b,c;
	S("%d %d %d", &a, &b, &c);
	int out = 0;
	int min = a / 3;
	min = b / 2 < min ? b / 2 : min;
	min = c / 2 < min ? c / 2 : min;
	out += min * 7;
	int arr[7];
	int x = 0;
	while (x < 7)
	{
		int ta,tb,tc;
		ta = a - min * 3;
		tb = b - min * 2;
		tc = c - min * 2;
		int count = 0;
		while (1)
		{
			if ((x + count) % 7 == 0 || (x + count) % 7 == 3 || (x + count) % 7 == 6 )
			{
				if (ta == 0)
					break;
				ta--;
			}
			else if ((x + count) % 7 == 1 || (x + count) % 7 == 5)
			{
				if (tb == 0)
					break;
				tb--;
			}
			else if ((x + count) % 7 == 2 || (x + count) % 7 == 4)
			{
				if (tc == 0)
					break;
				tc--;
			}
			count++;
		}
		arr[x] = count;
		x++;
	}
	qsort(arr, 7, SI(int), cmp);
	P("%d", out + arr[6]);
}

/*  AUTHOR:AKASH JAIN
*   USERNAME:akash19jain
*   DATE:18/04/2019
*/
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
int cmp(const void * a,const void * b)
{
    return (*(int*)a - *(int*)b);
}
int main()
{
    long long t=1;
    //scanf("%lld",&t);
    while(t--)
    {
        long long a,b,c,min;
        scanf("%lld%lld%lld",&a,&b,&c);
        long long a1=a/3,b1=b/2,c1=c/2;
        if(a1<=b1 && a1<=c1)
            min=a1;
        else if(b1<=a1 && b1<=c1)
            min=b1;
        else
            min=c1;

        a-=min*3;
        b-=min*2;
        c-=min*2;
        long long arr[3]={a,b,c};
        int idx[]={0,1,2,0,2,1,0};
        int b2[7];
        long long ans=0,f=0;
        for(int i=0;i<7;i++)
        {
            int day=i;
            int cur=0;
            b2[0]=arr[0],b2[1]=arr[1],b2[2]=arr[2];
            while(b2[idx[day]]>0)
            {
                --b2[idx[day]];
			    day = (day + 1) % 7;
			    ++cur;
            }
            if(min*7+cur>ans)
                ans=min*7+cur;
            else
                ans=ans;
        }

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

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

int compare_char(char *a,char *b){
	return strcmp(a,b);
}

int intsort(const void *a, const void *b){
	return *(int*)b - *(int*)a;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}

int main(){
	int i,N,j,p,a[4]={0},b[i],cnt=0,min,ans=0,x,y,z,day=0;
	for(i=0;i<3;i++){
	scanf("%d",&a[i]);
	}
/*	if(a[0]%3==0){
*/

b[0]=a[0]/3;
min=b[0];
/*	}else{
		b[0]=a[0]/3+1;
	}
	if(a[1]%2==0){
*/
b[1]=a[1]/2;
if(min>b[1])min=b[1];
/*	}else{
		b[1]=a[1]/2+1;
	}
	if(a[2]%2==0){
*/
b[2]=a[2]/2;
if(min>b[2])min=b[2];
/*	}else{
		b[2]=a[2]/2+1;
	}
*/

ans=min*7;
a[0]-=3*min;
a[1]-=2*min;
a[2]-=2*min;
min=0;
x=a[0];
y=a[1];
z=a[2];
	//sun
	while(1){
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	}
	min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
				//月
	while(1){
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
			//火曜
	while(1){
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
			//水曜
	while(1){
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
			//木曜
	while(1){
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
			//金曜
	while(1){
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

day=0;
x=a[0];
y=a[1];
z=a[2];

			//土曜
	while(1){
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

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

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

const char str[14]={'f','f','r','c','f','c','r','f','f','r','c','f','c','r'};

int findMax(int f, int r, int c);
int find(int start, int f, int r, int c);

int main(void)
{
    int f,r,c,d=0;
    scanf("%d %d %d", &f, &r, &c);

    for(;;)
    {
        if(f>=3 && r>=2 && c>=2)
        {
            f-=3;
            r-=2;
            c-=2;
            d+=7;
        }
        else
        {
            break;
        }
    }

    printf("%d", d+findMax(f, r, c));

    return 0;
}

int findMax(int f, int r, int c)
{
    int i, max=0;

    for(i=0; i<7; i++)
    {
        if(max<find(i, f, r, c))
        {
            max=find(i, f, r, c);
        }
    }
    return max;
}

int find(int start, int f, int r, int c)
{
    int i, day=0;

    for(i=0;;i++)
    {
        if(f>0 && str[start+i]=='f')
        {
            day++;
            f-=1;
        }
        else if(r>0 && str[start+i]=='r')
        {
            day++;
            r-=1;
        }
        else if(c>0 && str[start+i]=='c')
        {
            day++;
            c-=1;
        }
        else
        {
            break;
        }
    }

    return day;
}

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

const int CAT[7] = {
  0,0,1,2,0,2,1
};

int SUR = 0;
int maksus;
int AHAN[3];

int main(){
    scanf("%d %d %d",&AHAN[0],&AHAN[1],&AHAN[2]);
    int d=(MIN(AHAN[0]/3,(MIN(AHAN[1]/2,AHAN[2]/2))));
    AHAN[0]-=d*3;AHAN[1]-=d*2;AHAN[2]-=d*2;
    SUR += d*7;

    for(int i=0;i<7;i++){
        int Tod[3];for(int i=0;i<3;i++)Tod[i]=AHAN[i];
        int tn=0;
        for(int j=0;j<6;j++){
            if(Tod[CAT[(i+j)%7]]!=0){
                Tod[CAT[(i+j)%7]]--;
                tn++;
            }
            else{
              goto job;
            }
        }
        job:;
        maksus = MAX(maksus,tn);
    }
      printf("%d",SUR+maksus);
}

/* https://codeforces.com/contest/1154/submission/53710754 (rainboy) */
#include <stdio.h>

int aa[] = { 0, 1, 2, 0, 2, 1, 0, 0, 1, 2, 0, 2, 1, 0 };

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

int main() {
	int a, b, c, x, i, j, max;

	scanf("%d%d%d", &a, &b, &c);
	x = min(a / 3, min(b / 2, c / 2));
	a -= x * 3;
	b -= x * 2;
	c -= x * 2;
	max = 0;
	for (i = 0; i < 7; i++) {
		int a_ = a, b_ = b, c_ = c;

		for (j = i; j < 14; j++)
			if (aa[j] == 0) {
				if (a_-- == 0)
					break;
			} else if (aa[j] == 1) {
				if (b_-- == 0)
					break;
			} else
				if (c_-- == 0)
					break;
		if (max < j - i)
			max = j - i;
	}
	printf("%d\n", x * 7 + max);
	return 0;
}

#include <stdio.h>

int main(void){
	int arr[7]={0,};
	int i, j, A, B, C, a, b, c, weekday, cnt, max=0;

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

	for(i=0; i<7; i++){
		a=A;
		b=B;
		c=C;
		cnt=0;
		weekday=i;

		max=A/3;
		if(max>B/2){
			max=B/2;
		}
		if(max>C/2){
			max=C/2;
		}

		a-=max*3;
		b-=max*2;
		c-=max*2;
		cnt+=max*7;

		while(a!=-1 && b!=-1 && c!=-1){
			if(weekday%7==1 || weekday%7==4 || weekday%7==0){
				a--;
			}
			else if(weekday%7==2 || weekday%7==6){
				b--;
			}
			else{
				c--;
			}
			weekday++;
			cnt++;
		}
		arr[i]=cnt;
	}

	for(i=0; i<7; i++){
		if(max<arr[i]){
			max=arr[i];
		}
	}

	printf("%d", max-1);

	return 0;
}

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

int main(){

	int a,b,c;
	int week[8],sum = 0,i,max = -1,x,ans = 0;

	scanf("%d%d%d",&a,&b,&c);
	while (a>=3 && b>=2 && c>=2){
		a-=3;
		b-=2;
		c-=2;
		sum+=7;
	}
	for (i=0;i<7;i++){
		week[0] = a;
		week[1] = b;
		week[2] = c;
		week[3] = a;
		week[4] = c;
		week[5] = b;
		week[6] = a;
		x = i;
		ans = 0;
		while (week[x]){
			switch(x){
				case 0 : week[0]--; week[3]--; week[6]--; break;
				case 1 : week[1]--; week[5]--; break;
				case 2 : week[2]--; week[4]--; break;
				case 3 : week[0]--; week[3]--; week[6]--; break;
				case 4 : week[2]--; week[4]--; break;
				case 5 : week[1]--; week[5]--; break;
				case 6 : week[0]--; week[3]--; week[6]--; break;
			}
			ans++;
			x = (x + 1)%7;
		}
		if (max < ans) max = ans;
	}
	printf("%d",max+sum);
	return 0;
}

#include <stdio.h>
typedef long long int ll;
ll min(ll a, ll b, ll c)
{
    if (a <= b && a <= c)
    {
        return a;
    }
    else if (b <= a && b <= c)
    {
        return b;
    }
    else
        return c;
}
int main()
{
    int arr[7] = {0, 1, 2, 0, 2, 1, 0};
    ll f, r, c;
    ll days = 0;
    scanf("%lld %lld %lld", &f, &r, &c);

    ll x = min(f / 3, (r) / 2, (c) / 2);
    days = x * 7;
    f -= 3 * x;
    r -= 2 * x;
    c -= 2 * x;

    // while (f >= 2 && r >= 2 && f >= 3)
    // {
    //     days += 7;
    //     r -= 2;
    //     f -= 3;
    //     c -= 2;
    // }
    ll max = 0;
    for (int i = 0; i < 7; i++)
    {

        ll p[3] = {f, r, c};
        ll j = i;
        ll d = 0;
        while (p[arr[j]] > 0)
        {
            p[arr[j]]--;
            d++;
            j++;
            if (j == 7)
            {
                j = 0;
            }
        }
        //printf("%lld\n", d);
        if (max < d)
        {
            max = d;
        }
    }
    days += max;
    printf("%lld", days);
}

#include <stdio.h>

int main()
{
    long long a, b, c;
    scanf("%lld %lld %lld", &a, &b, &c);

    long long p = a, q = b, r = c;
    p = p / 3;
    q = q / 2;
    r = r / 2;

    long long min = p;
    if (q < min)
    {
        min = q;
    }
    if (r < min)
    {
        min = r;
    }
    p = a;
    q = b;
    r = c;

    long long int count = 1;
    long long int max = -1;

    for (long long int i = 1; i <= 7; i++)
    {
        count = i;

        a = p - min * 3;
        b = q - min * 2;
        c = r - min * 2;
        //printf("STARTING DY OF WEEK IS %lld\n", i);

        while (a >= 0 && b >= 0 && c >= 0)
        {

            if (count % 7 == 1)
            {
                a--;
            }
            if (count % 7 == 2)
            {
                a--;
            }
            if (count % 7 == 3)
            {
                b--;
            }
            if (count % 7 == 4)
            {
                c--;
            }
            if (count % 7 == 5)
            {
                a--;
            }
            if (count % 7 == 6)
            {
                c--;
            }
            if (count % 7 == 0)
            {
                b--;
            }

            count++;
        }

        count -= i + 1;

        if (max < count)
        {
            max = count;
        }
    }

    max = max + 7 * min;
    printf("%lld", max);

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int cmpfun(const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}
int main()
{
    int a,ac,b,bc,cc,c,n,i,days=0,day,j,d[3];
    scanf("%d %d %d",&a,&b,&c);
    d[0]=a/3;
    d[1]=b/2;
    d[2]=c/2;
    qsort(d,3,sizeof(int),cmpfun);

    day=d[0]*7;
    a-=(d[0]*3);
    b-=(d[0]*2);
    c-=(d[0]*2);

    for(j=1;j<8;j++)
    {
        n=0;
        ac=a;
        bc=b;
        cc=c;
        i=j;
        while(1)
        {

            if(i==1||i==4||i==7)
            {
                if(ac==0)break;
                ac--;
            }
            else if(i==2||i==6)
            {
                if(bc==0)break;
                bc--;
            }
            else
            {
                if(cc==0)break;
                cc--;
            }
            if(i==7)i=1;
            else i++;
            n++;
            //printf("%d %d %d\n",ac,bc,cc);
        }
        if(days<n)days=n;
    }
    printf("%d",days+day);
}

#include<stdio.h>

int min(int a, int b, int c)
{
	int	min = a;
	if(b<min)
		min = b;
	if(c<min)
		min = c;
	return min;
}

int main()
{
	//F R C F C R F
	int a, b, c, mini, max, set, a1, a2, a3;
	int arr[7];

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

	mini = min(a/3, b/2, c/2);
	a = a - mini*3;
	b = b - mini*2;
	c = c - mini*2;

	//printf("%d and %d and %d and %d\n", mini, a, b, c);

	for(int j =0; j<7; j++)
	{
		a1= a;
		a2 = b;
		a3 = c;
		for(int i = 0; i<7; i++)
		{
			if((i+j)%7 == 0 || (i+j)%7 == 3 || (i+j)%7 == 6)
				{
					if(a1 == 0){
						set = i;
						break;
					}
					else{
						a1--;
						//printf("a %d\n", i);
					}
				}
			if((i+j)%7 == 1 || (i+j)%7 == 5)
				{
					if(a2 == 0){
						set = i;
						break;
					}
					else{
						a2--;
						//printf("b %d\n", i);
					}
				}
			if((i+j)%7 == 2 || (i+j)%7 == 4)
				{
					if(a3 == 0){
						set = i;
						break;
					}
					else{
						a3--;
						//printf("c %d\n", i);
					}
				}
		}
		if(j == 0)
			max = set;
		else
		{
			if(set>max)
				max = set;
		}
		//printf("max in run %d is %d\n", j, max);

	}

	printf("%d\n", max + 7*mini);
	return 0;
}

#include <stdio.h>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)>(b)?(b):(a))
int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int na = a / 3, nb = b / 2, nc = c / 2;
    int ans = min(na, min(nb, nc));
    na = min(3, a-ans*3), nb = min(2, b-ans*2), nc = min(2, c-ans*2);
    ans *= 7;
    const char s[] = {'a', 'b', 'c', 'a', 'c', 'b', 'a'};
    int maxv = 0;
    for(int i = 0; i < 7; i++)
    {
        int j = i, value = 0;
        int tmpa = na, tmpb = nb, tmpc = nc;
        while(tmpa > 0 || tmpb > 0 || tmpc > 0)
        {
            if(s[j] == 'a')
            {
                if(tmpa <= 0) break;
                tmpa--;
            }
            else if(s[j] == 'b')
            {
                if(tmpb <= 0) break;
                tmpb--;
            }
            else
            {
                if(tmpc <= 0) break;
                tmpc--;
            }
            j = (j+1)%7;
            value++;
        }
        maxv = max(maxv, value);
    }
    printf("%d\n", ans+maxv);
}

#include<stdio.h>
int chi(int n,int a,int b,int c)
{
	int count = 0;
	while(1)
	{
		int yu = n % 7;
		if(yu == 1 || yu == 4 || yu == 0)
		{
			a--;
			if(a >= 0)
				count++;
			else
				return count;
		}
		if(yu == 2 || yu == 6)
		{
			b--;
			if(b >= 0)
				count++;
			else
				return count;
		}
		if(yu == 3 || yu == 5)
		{
			c--;
			if(c >= 0)
				count++;
			else
				return count;
		}
		n++;
	}
}
int main()
{
	int a,b,c;
	while(scanf("%d %d %d",&a,&b,&c) != EOF)
	{
		int day = 0;
		int week;
		int m = a / 3;
		int n = b / 2;
		int o = c / 2;
		week = m;
		if(week > n)
			week = n;
		if(week > o)
			week = o;
		day = week * 7;
		a = a - week * 3;
		b = b - week * 2;
		c = c - week * 2;
		int max = 0;
		for(int i=0;i<7;i++)
		{
			int temp = chi(i,a,b,c);
			if(max < temp)
				max = temp;
		}
		day += max;
		printf("%d\n",day);
	}
}

#include<stdio.h>
int menu[8]={1,2,3,1,3,2,1};
int lastweek(int f,int r,int c,int offset)
{
	int i,daysfed=0;
	for(i=offset;i<offset+10;i++)
	{
		switch(menu[i%7]-1)
		{
			case 0:
			case 3:
			case 6:
				if(f==0)
					return daysfed;
				f--;
				daysfed++;
				break;
			case 1:
			case 5:
				if(r==0)
					return daysfed;
				r--;
				daysfed++;
				break;
			case 2:
			case 4:
				if(c==0)
					return daysfed;
				c--;
				daysfed++;
				break;
		}
	}
	return daysfed;
}
int main()
{
	int f,r,c,min_weeks,max_days;
	scanf("%d%d%d",&f,&r,&c);
	min_weeks=f/3;
	if(min_weeks>r/2)min_weeks=r/2;
	if(min_weeks>c/2)min_weeks=c/2;
	f-=3*min_weeks;
	r-=2*min_weeks;
	c-=2*min_weeks;
	max_days=min_weeks*7;
	int Max=0,i,val;
	for(i=0;i<7;i++)
	{
		val=lastweek(f,r,c,i);
		if(Max<val)
			Max=val;
	}
	printf("%d\n",Max+max_days);
	return 0;
}

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

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

int main(){
	// 1, 4, 7: fish
	// 2, 6: 	rabbit
	// 3, 5: 	chicken

	int f, r, c;
	scanf("%d%d%d", &f, &r, &c);

	int base = min(min(f/3, r/2), c/2);	/*base weeks*/

	f -= 3 * base;
	r -= 2 * base;
	c -= 2 * base;

	int day = base * 7;
	int max = day;

	int tmp;

	for(int i = 1; i <= 7; ++i){
		// start at day i
		tmp = day;
		for(int j = 0, done = 0; !done; ++j){
			switch( (i+j) % 7 ){
				case 1: case 4: case 0:	/* fish */
					if(f > 0){
						f--;
						tmp++;
					}else{
						done = 1;
					}
					break;
				case 2: case 6:			/* rabbit */
					if(r > 0){
						r--;
						tmp++;
					}else{
						done = 1;
					}
					break;
				default:				/* chicken */
					if(c > 0){
						c--;
						tmp++;
					}else{
						done = 1;
					}
					break;
			}
		}
		if(tmp > max) max = tmp;
	//	printf("i = %d, count = %d\n", i, tmp);
	}

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

	return 0;
}

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

int compare_char(char *a,char *b){
	return strcmp(a,b);
}

int intsort(const void *a, const void *b){
	return *(int*)b - *(int*)a;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}

int main(){
	int i,N,j,p,a[4]={0},b[i],cnt=0,min,ans=0,x,y,z,day=0;
	for(i=0;i<3;i++){
	scanf("%d",&a[i]);
	}
/*	if(a[0]%3==0){
*/

b[0]=a[0]/3;
min=b[0];
/*	}else{
		b[0]=a[0]/3+1;
	}
	if(a[1]%2==0){
*/
b[1]=a[1]/2;
if(min>b[1])min=b[1];
/*	}else{
		b[1]=a[1]/2+1;
	}
	if(a[2]%2==0){
*/
b[2]=a[2]/2;
if(min>b[2])min=b[2];
/*	}else{
		b[2]=a[2]/2+1;
	}
*/
ans=min*7;
a[0]-=7*min;
a[1]-=7*min;
a[2]-=7*min;
min=0;
x=a[0];
y=a[1];
z=a[2];
//sun
while(1){
if(x>0){
x--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
if(y>0){
y--;
day++;
}else{
break;
}
if(z>0){
z--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
if(z>0){
z--;
day++;
}else{
break;
}
if(y>0){
y--;
day++;
}else{
break;
}
}
min=day;

day=0;
x=a[0];
y=a[1];
z=a[2];
//月
while(1){
if(x>0){
x--;
day++;
}else{
break;
}
if(y>0){
y--;
day++;
}else{
break;
}
if(z>0){
z--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
if(z>0){
z--;
day++;
}else{
break;
}
if(y>0){
y--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
}
if(min<day)min=day;

day=0;
x=a[0];
y=a[1];
z=a[2];
//月
while(1){
if(y>0){
y--;
day++;
}else{
break;
}
if(z>0){
z--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
if(z>0){
z--;
day++;
}else{
break;
}
if(y>0){
y--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
}
if(min<day)min=day;

day=0;
x=a[0];
y=a[1];
z=a[2];
//月
while(1){
if(z>0){
z--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
if(z>0){
z--;
day++;
}else{
break;
}
if(y>0){
y--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
if(y>0){
y--;
day++;
}else{
break;
}
}
if(min<day)min=day;

day=0;
x=a[0];
y=a[1];
z=a[2];
//月
while(1){
if(x>0){
x--;
day++;
}else{
break;
}
if(z>0){
z--;
day++;
}else{
break;
}
if(y>0){
y--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
if(y>0){
y--;
day++;
}else{
break;
}
if(z>0){
z--;
day++;
}else{
break;
}
}
if(min<day)min=day;

day=0;
x=a[0];
y=a[1];
z=a[2];
//月
while(1){
if(z>0){
z--;
day++;
}else{
break;
}
if(y>0){
y--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
if(y>0){
y--;
day++;
}else{
break;
}
if(z>0){
z--;
day++;
}else{
break;
}
if(x>0){
x--;
day++;
}else{
break;
}
}
if(min<day)min=day;

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

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

int compare_char(char *a,char *b){
	return strcmp(a,b);
}

int intsort(const void *a, const void *b){
	return *(int*)b - *(int*)a;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}

int main(){
	int i,N,j,p,a[4]={0},b[i],cnt=0,min,ans=0,x,y,z,day=0;
	for(i=0;i<3;i++){
	scanf("%d",&a[i]);
	}
/*	if(a[0]%3==0){
*/

b[0]=a[0]/3;
min=b[0];
/*	}else{
		b[0]=a[0]/3+1;
	}
	if(a[1]%2==0){
*/
b[1]=a[1]/2;
if(min>b[1])min=b[1];
/*	}else{
		b[1]=a[1]/2+1;
	}
	if(a[2]%2==0){
*/
b[2]=a[2]/2;
if(min>b[2])min=b[2];
/*	}else{
		b[2]=a[2]/2+1;
	}
*/

ans=min*7;
a[0]-=3*min;
a[1]-=2*min;
a[2]-=2*min;
min=0;
x=a[0];
y=a[1];
z=a[2];
	//sun
	while(1){
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	}
	min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
				//月
	while(1){
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
			//火曜
	while(1){
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
			//水曜
	while(1){
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
			//木曜
	while(1){
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
			//金曜
	while(1){
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;
			//土曜
	while(1){
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

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

#include <stdio.h>

int main(void){
	int arr[7]={0,};
	int i, A, B, C, a, b, c, weekday, cnt, max=0;

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

	for(i=0; i<7; i++){
		a=A;
		b=B;
		c=C;
		cnt=0;
		weekday=i;
		while(a!=-1 && b!=-1 && c!=-1){
			if(weekday%7==1 || weekday%7==4 || weekday%7==0){
				a--;
			}
			else if(weekday%7==2 || weekday%7==6){
				b--;
			}
			else{
				c--;
			}
			weekday++;
			cnt++;
		}
		arr[i]=cnt;
	}

	printf("a: %d / b: %d / c: %d\n", a, b, c);
	for(i=0; i<7; i++){
		printf("%d ", arr[i]);
		if(max<arr[i]){
			max=arr[i];
		}
	}
	printf("\n");

	printf("%d", max-1);

	return 0;
}

#include<stdio.h>

int min(int a, int b, int c)
{
	int	min = a;
	if(b<min)
		min = b;
	if(c<min)
		min = c;
	return min;
}

int main()
{
	//F R C F C R F
	int a, b, c, mini, max, set, a1, a2, a3;
	int arr[7];

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

	mini = min(a/3, b/2, c/2);
	a = a - mini*3;
	b = b - mini*2;
	c = c - mini*2;

	printf("%d and %d and %d and %d\n", mini, a, b, c);

	for(int j =0; j<7; j++)
	{
		a1= a;
		a2 = b;
		a3 = c;
		for(int i = 0; i<7; i++)
		{
			if((i+j)%7 == 0 || (i+j)%7 == 3 || (i+j)%7 == 6)
				{
					if(a1 == 0){
						set = i;
						break;
					}
					else{
						a1--;
						printf("a %d\n", i);
					}
				}
			if((i+j)%7 == 1 || (i+j)%7 == 5)
				{
					if(a2 == 0){
						set = i;
						break;
					}
					else{
						a2--;
						printf("b %d\n", i);
					}
				}
			if((i+j)%7 == 2 || (i+j)%7 == 4)
				{
					if(a3 == 0){
						set = i;
						break;
					}
					else{
						a3--;
						printf("c %d\n", i);
					}
				}
		}
		if(j == 0)
			max = set;
		else
		{
			if(set>max)
				max = set;
		}
		printf("max in run %d is %d\n", j, max);

	}

	printf("%d\n", max + 7*mini);
	return 0;
}

#include<stdio.h>

int min(int a, int b, int c)
{
	int	min = a;
	if(b<min)
		min = b;
	if(c<min)
		min = c;
	return min;
}

int main()
{
	//F R C F C R F
	int a, b, c, mini, max, set;
	int arr[7];

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

	mini = min(a/3, b/2, c/2);
	a = a - mini*3;
	b = b - mini*2;
	c = c - mini*2;
	printf("%d and %d and %d and %d\n", mini, a, b, c);

	for(int j =0; j<7; j++)
	{
		for(int i = 0; i<7; i++)
		{
			if((i+j)%7 == 0 || (i+j)%7 == 3 || (i+j)%7 == 6)
				{
					if(a == 0){
						set = i;
						break;
					}
					else{
						a--;
						//printf("a %d\n", i);
					}
				}
			if((i+j)%7 == 1 || (i+j)%7 == 5)
				{
					if(b == 0){
						set = i;
						break;
					}
					else{
						b--;
						//printf("b %d\n", i);
					}
				}
			if((i+j)%7 == 2 || (i+j)%7 == 4)
				{
					if(c == 0){
						set = i;
						break;
					}
					else{
						c--;
						//printf("c %d\n", i);
					}
				}
		}
		if(j == 0)
			max = set;
		else
		{
			if(set>max)
				max = set;
		}
		//printf("max in run %d is %d\n", j, max);

	}

	printf("%d\n", max + 7*mini);
	return 0;
}

#include<stdio.h>

int min(int a, int b, int c)
{
	int	min = a;
	if(b<min)
		min = b;
	if(c<min)
		min = c;
	return min;
}

int main()
{
	//F R C F C R F
	int a, b, c, mini, max, set;
	int arr[7];

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

	mini = min(a/3, b/2, c/2);
	a = a - mini*3;
	b = b - mini*2;
	c = c - mini*2;

	for(int j =0; j<7; j++)
	{
		for(int i = 0; i<7; i++)
		{
			if((i+j)%7 == 0 || (i+j)%7 == 3 || (i+j)%7 == 6)
				{
					if(a == 0){
						set = i;
						break;
					}
					else{
						a--;
					}
				}
			if((i+j)%7 == 1 || (i+j)%7 == 5)
				{
					if(b == 0){
						set = i;
						break;
					}
					else
						b--;
				}
			if((i+j)%7 == 2 || (i+j)%7 == 4)
				{
					if(c == 0){
						set = i;
						break;
					}
					else
						c--;
				}
		}
		if(j == 0)
			max = set;
		else
		{
			if(set>max)
				max = set;
		}

	}

	printf("%d\n", max + 7*mini);
	return 0;
}

#include <stdio.h>
#define min(a,b) ((a)>(b)?(b):(a))
int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int na = a / 3, nb = b / 2, nc = c / 2;
    int ans = min(na, min(nb, nc));
    na = a - ans*3, nb = b - ans*2, nc = c - ans*2;
    ans *= 7;
//    printf("remain a=%d, b=%d, c=%d, ans=%d\n", na, nb, nc, ans);
    na = min(2, na);
    nb = min(na, nb);
    nc = min(nb, nc);
    ans += na + nb + nc;
    printf("%d\n", ans);
}

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

int main(){

    long long  totald,min,a,b,c,ca,cb,cc;
    scanf("%lld%lld%lld",&a,&b,&c);
    ca=a/3;a=a%3;
    cb=b/2;b=b%2;
    cc=c/2;c=c%2;
    min=ca<cb?(ca<cc?ca:cc):(cb<cc?cb:cc);
    ca-=min;
    cb-=min;
    cc-=min;
    totald=min*7;
    a+=ca*3;
    b+=cb*2;
    c+=cc*2;

     //printf("%lld %lld %lld %lld\n",a,b,c,totald);

    long long count,max=-1,tmpa,tmpb,tmpc,arr[7];
    for(int i=0;i<7; i++){
        tmpa=a;
        tmpb=b;
        tmpc=c;
        memset(arr,0,sizeof(arr));
        for(int j=i;j<7; j++){
            if((j==0 || j==3) && tmpb){
                arr[j]=1;
                tmpb--;
            }
            else if((j==1 || j==2 || j== 5 )&& tmpa){
                arr[j]=2;
                tmpa--;
            }
            else if((j==4 || j==6 )&& tmpc){
                arr[j]=3;
                tmpc--;
            }
        }
        count=0;
        for(int k=i;k<7; k++){
            if(arr[k]==0)break;
          //printf("%d ",arr[k] );
            count++;
        }
      //puts("");
        if(count>max){
            max=count;
        }
    }
    printf("%lld\n",totald+max);
    return 0;
}

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

int main(){

    long long  totald,min,a,b,c,ca,cb,cc;
    scanf("%lld%lld%lld",&b,&a,&c);
    ca=a/3;a=a%3;
    cb=b/2;b=b%2;
    cc=c/2;c=c%2;
    min=ca<cb?(ca<cc?ca:cc):(cb<cc?cb:cc);
    ca-=min;
    cb-=min;
    cc-=min;
    totald=min*7;
    a+=ca*3;
    b+=cb*2;
    c+=cc*2;

  // printf("%lld %lld %lld %lld\n",a,b,c,totald);

    long long count,max=-1,tmpa,tmpb,tmpc,arr[7];
    for(int i=0;i<7; i++){
        tmpa=a;
        tmpb=b;
        tmpc=c;
        memset(arr,0,sizeof(arr));
        for(int j=i;j<7; j++){
            if((j==0 || j==3) && tmpa){
                arr[j]=1;
                tmpa--;
            }
            else if((j==1 || j==2 || j== 5 )&& tmpb){
                arr[j]=2;
                tmpb--;
            }
            else if(j==4 || j==6 && tmpc){
                arr[j]=3;
                tmpc--;
            }
        }
        count=0;
        for(int k=i;k<7; k++){
            if(arr[k]==0)break;
         //   printf("%d ",arr[k] );
            count++;
        }
       // puts("");
        if(count>max){
            max=count;
        }
    }
    printf("%lld\n",totald+max);
    return 0;
}

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

int main(){

    long long  totald,min,a,b,c,ca,cb,cc;
    scanf("%lld%lld%lld",&a,&b,&c);
    ca=a/3;a=a%3;
    cb=b/2;b=b%2;
    cc=c/2;c=c%2;
    min=ca<cb?(ca<cc?ca:cc):(cb<cc?cb:cc);
    ca-=min;
    cb-=min;
    cc-=min;
    totald=min*7;
    a+=ca*3;
    b+=cb*2;
    c+=cc*2;

   //printf("%lld %lld %lld %lld\n",a,b,c,totald);

    long long count,max=-1,tmpa,tmpb,tmpc,arr[7];
    for(int i=0;i<7; i++){
        tmpa=a;
        tmpb=b;
        tmpc=c;
        memset(arr,0,sizeof(arr));
        for(int j=i;j<7; j++){
            if((j==0 || j==3) && tmpa){
                arr[j]=1;
                tmpa--;
            }
            else if((j==1 || j==2 || j== 5 )&& tmpb){
                arr[j]=2;
                tmpb--;
            }
            else if(tmpc){
                arr[j]=3;
                tmpc--;
            }
        }
        count=0;
        for(int k=i;k<7; k++){
            if(arr[k]==0)break;
            count++;
        }
        if(count>max){
            max=count;
        }
    }
    printf("%lld\n",totald+max);
    return 0;
}

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

int main(){

    long long  totald,min,a,b,c,ca,cb,cc;
    scanf("%lld%lld%lld",&b,&a,&c);
    ca=a/3;a=a%3;
    cb=b/2;b=b%2;
    cc=c/2;c=c%2;
    min=ca<cb?(ca<cc?ca:cc):(cb<cc?cb:cc);
    ca-=min;
    cb-=min;
    cc-=min;
    totald=min*7;
    a+=ca*3;
    b+=cb*2;
    c+=cc*2;

     //printf("%lld %lld %lld %lld\n",b,a,c,totald);

    long long count,max=-1,tmpa,tmpb,tmpc,arr[7];
    for(int i=0;i<7; i++){
        tmpa=a;
        tmpb=b;
        tmpc=c;
        memset(arr,0,sizeof(arr));
        for(int j=i;j<7; j++){
            if((j==0 || j==3) && tmpa){
                arr[j]=1;
                tmpa--;
            }
            else if((j==1 || j==2 || j== 5 )&& tmpb){
                arr[j]=2;
                tmpb--;
            }
            else if((j==4 || j==6 )&& tmpc){
                arr[j]=3;
                tmpc--;
            }
        }
        count=0;
        for(int k=i;k<7; k++){
            if(arr[k]==0)break;
           //printf("%d ",arr[k] );
            count++;
        }
       //puts("");
        if(count>max){
            max=count;
        }
    }
    printf("%lld\n",totald+max);
    return 0;
}

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

long long a ,b,c,mini,nr;

int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&c);
mini=a/3;
if(b/2 <mini)
    mini=b/2;
if(c/2 <mini)
    mini=c/2;
if(mini>1)
{

a=a-3*mini;
b=b-2*mini;
c=c-2*mini;
nr=mini*7;

}
if(a>3)
    a=3;
if(b>2)
    b=2;
if(c>2)
    c=2;
printf("%I64d %I64d %I64d ",a,b,c);
if(a==b && b==c)
    nr=nr+a+b+c;
if(a>b && a>c)
{
    if(b==0 && c==0)
        nr=nr+2;
        else
    if(b==c)
        nr=nr+a+b+c;
    else
    {
        if(b!=0 && c!=0)
            nr=nr+6;
        else
        {
            if(a==2)
                if(c==1)
                  nr=nr+3;
                else
                    if(b==1)
                        nr=nr+3;
            if(a==3)
            {
                if(b>0)
                    nr=nr+b+2;
                if(c>0)
                    nr=nr+c+1;
                }
        }
    }

}
else
if(b>a || c>a)
{

    if(b!=0 && c!=0 && a>0)
    {

        if(c==2)
            nr=nr+a+b+c;
        else
            nr=nr+3;

    }
    else
        if(a==0 && c>0 && c>0)
            nr=nr+2;
    else

        nr++;

}
else

    if(a==b || a==c )
        if(b!=c)
        if(b==0 )
            nr=nr+3;
        else
            nr=nr+a+b+c;

printf("%I64d",nr);

    return 0;
}

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

long long a ,b,c,mini,nr;

int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&c);
if(a>3 || b>2 || c>2)
{

mini=a/3;
if(b/2 <mini)
    mini=b/2;
if(c/2 <mini)
    mini=c/2;
}

a=a-3*mini;
b=b-2*mini;
c=c-2*mini;
nr=mini*7;
if(a>3)
    a=3;
if(b>2)
    b=2;
if(c>2)
    c=2;

if(a==b && b==c)
    nr=nr+a+b+c;
if(a>b && a>c)
{
    if(b==0 && c==0)
        nr=nr+2;
        else
    if(b==c)
        nr=nr+a+b+c;
    else
    {
        if(b!=0 && c!=0)
            nr=nr+6;
        else
        {
            if(a==2)
                if(c==1)
                  nr=nr+3;
                else
                    if(b==1)
                        nr=nr+3;
            if(a==3)
            {
                if(b>0)
                    nr=nr+b+2;
                if(c>0)
                    nr=nr+c+1;
                }
        }
    }

}
else
if(b>a || c>a)
{

    if(a>0)
    {

        if(b==0 || c==0)
        {

        if(b==0)
            nr=nr+3;
        if(c==0)
            nr=nr+2;

        }

    if(b!=0 && c!=0 )
    {

        if(c==2)
            nr=nr+a+b+c;
        else
            nr=nr+3;

    }
    }
    else
        if(a==0 && c>0 && b>0)
            nr=nr+2;
    else

        nr++;

}
else

    if(a==b || a==c )
        if(b!=c)
        if(b==0 )
            nr=nr+3;
        else
            nr=nr+a+b+c;

printf("%I64d",nr);

    return 0;
}

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

long long a ,b,c,mini,nr;

int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&c);
mini=a/3;
if(b/2 <mini)
    mini=b/2;
if(c/2 <mini)
    mini=c/2;

a=a-3*mini;
b=b-2*mini;
c=c-2*mini;
if(a>3)
    a=3;
if(b>2)
    b=2;
if(c>2)
    c=2;
nr=mini*7;
if(a==b && b==c)
    nr=nr+a+b+c;
if(a>b && a>c)
{
    if(b==0 && c==0)
        nr=nr+2;
        else
    if(b==c)
        nr=nr+a+b+c;
    else
    {
        if(b!=0 && c!=0)
            nr=nr+6;
        else
        {
            if(a==2)
                if(c==1)
                  nr=nr+3;
                else
                    if(b==1)
                        nr=nr+3;
            if(a==3)
            {
                if(b>0)
                    nr=nr+b+2;
                if(c>0)
                    nr=nr+c+1;
                }
        }
    }

}
else
{if(b>a || c>a)
    if(b!=0 && c!=0 && a>0)
    {

        if(c==2)
            nr=nr+a+b+c;
        else
            nr=nr+3;

    }
    else
        if(a==0 && c>0 && c>0)
            nr=nr+2;
    else

        nr++;

}

printf("%I64d",nr);

    return 0;
}

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

long long a ,b,c,mini,nr;

int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&c);
mini=a/3;
if(b/2 <mini)
    mini=b/2;
if(c/2 <mini)
    mini=c/2;

a=a-3*mini;
b=b-2*mini;
c=c-2*mini;
if(a>3)
    a=3;
if(b>2)
    b=2;
if(c>2)
    c=2;
nr=mini*7;
if(a==b && b==c)
    nr=nr+a+b+c;
if(a>b && a>c)
{
    if(b==c)
        nr=nr+a+b+c;
    else
    {
        if(b!=0 && c!=0)
            nr=nr+6;
        else
        {
            if(a==2)
                if(c==1)
                  nr=nr+3;
                else
                    if(b==1)
                        nr=nr+3;
            if(a==3)
            {
                if(b>0)
                    nr=nr+b+2;
                if(c>0)
                    nr=nr+c+1;
                }
        }
    }

}
else
{if(b>a || c>a)
    if(b!=0 && c!=0 )
    {

        if(c==2)
            nr=nr+a+b+c;
        else
            nr=nr+3;

    }
    else

        nr++;

}

printf("%I64d",nr);

    return 0;
}

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

long long a ,b,c,mini,nr;

int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&c);
if(a>3 || b>2 || c>2)
{

mini=a/3;
if(b/2 <mini)
    mini=b/2;
if(c/2 <mini)
    mini=c/2;
}

a=a-3*mini;
b=b-2*mini;
c=c-2*mini;
nr=mini*7;
if(a>3)
    a=3;
if(b>2)
    b=2;
if(c>2)
    c=2;

if(a==b && b==c)
    nr=nr+a+b+c;
if(a>b && a>c)
{
    if(b==0 && c==0)
        nr=nr+2;
        else
    if(b==c)
        nr=nr+a+b+c;
    else
    {
        if(b!=0 && c!=0)
            nr=nr+6;
        else
        {
            if(a==2)
                if(c==1)
                  nr=nr+3;
                else
                    if(b==1)
                        nr=nr+3;
            if(a==3)
            {
                if(b>0)
                    nr=nr+b+2;
                if(c>0)
                    nr=nr+c+1;
                }
        }
    }

}
else
if(b>a || c>a)
{

    if(a>0)
        if(b==0 || c==0)
        {

        if(b==0)
            nr=nr+3;
        if(c==0)
            nr=nr+2;

        }

     else
    if(b!=0 && c!=0  && a>0)
    {

        if(c==2)
            nr=nr+a+b+c;
        else
            nr=nr+3;

    }
    else
        if(a==0 && c>0 && b>0)
            nr=nr+2;
    else

        nr++;

}
else

    if(a==b || a==c )
        if(b!=c)
        if(b==0 )
            nr=nr+3;
        else
            nr=nr+a+b+c;

printf("%I64d",nr);

    return 0;
}

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

long long a ,b,c,mini,nr;

int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&c);
mini=a/3;
if(b/2 <mini)
    mini=b/2;
if(c/2 <mini)
    mini=c/2;

a=a-3*mini;
b=b-2*mini;
c=c-2*mini;
if(a>3)
    a=3;
if(b>2)
    b=2;
if(c>2)
    c=2;
nr=mini*7;
if(a==b && b==c)
    nr=nr+a+b+c;
if(a>b && a>c)
{
    if(b==c)
        nr=nr+a+b+c;
    else
    {
        if(b!=0 && c!=0)
            nr=nr+6;
        else
        {
            if(a==2)
                if(c==1)
                  nr=nr+3;
                else
                    if(b==1)
                        nr=nr+3;
            if(a==3)
            {
                if(b>0)
                    nr=nr+b+2;
                if(c>0)
                    nr=nr+c+1;
                }
        }
    }

}
else
{if(b>a || c>a)
    if(b!=0 && c!=0 )
        nr=nr+a+2;
    else

        nr++;

}

printf("%I64d",nr);

    return 0;
}

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

long long a ,b,c,mini,nr;

int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&c);
if(a>3 || b>2 || c>2)
{

mini=a/3;
if(b/2 <mini)
    mini=b/2;
if(c/2 <mini)
    mini=c/2;
}

a=a-3*mini;
b=b-2*mini;
c=c-2*mini;
nr=mini*7;
if(a>3)
    a=3;
if(b>2)
    b=2;
if(c>2)
    c=2;

if(a==b && b==c)
    nr=nr+a+b+c;
if(a>b && a>c)
{
    if(b==0 && c==0)
        nr=nr+2;
        else
    if(b==c)
        nr=nr+a+b+c;
    else
    {
        if(b!=0 && c!=0)
            nr=nr+6;
        else
        {
            if(a==2)
                if(c==1)
                  nr=nr+3;
                else
                    if(b==1)
                        nr=nr+3;
            if(a==3)
            {
                if(b>0)
                    nr=nr+b+2;
                if(c>0)
                    nr=nr+c+1;
                }
        }
    }

}
else
if(b>a || c>a)
{
    if(a>0)
    {

        if(b==0)
            nr=nr+3;
        if(c==0)
            nr=nr+2;

    }

     else
    if(b!=0 && c!=0 && a>0)
    {

        if(c==2)
            nr=nr+a+b+c;
        else
            nr=nr+3;

    }
    else
        if(a==0 && c>0 && b>0)
            nr=nr+2;
    else

        nr++;

}
else

    if(a==b || a==c )
        if(b!=c)
        if(b==0 )
            nr=nr+3;
        else
            nr=nr+a+b+c;

printf("%I64d",nr);

    return 0;
}

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

long long a ,b,c,mini,nr;

int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&c);
mini=a/3;
if(b/2 <mini)
    mini=b/2;
if(c/2 <mini)
    mini=c/2;
if(mini>1)
{

a=a-3*mini;
b=b-2*mini;
c=c-2*mini;
nr=mini*7;

}
if(a>3)
    a=3;
if(b>2)
    b=2;
if(c>2)
    c=2;

if(a==b && b==c)
    nr=nr+a+b+c;
if(a>b && a>c)
{
    if(b==0 && c==0)
        nr=nr+2;
        else
    if(b==c)
        nr=nr+a+b+c;
    else
    {
        if(b!=0 && c!=0)
            nr=nr+6;
        else
        {
            if(a==2)
                if(c==1)
                  nr=nr+3;
                else
                    if(b==1)
                        nr=nr+3;
            if(a==3)
            {
                if(b>0)
                    nr=nr+b+2;
                if(c>0)
                    nr=nr+c+1;
                }
        }
    }

}
else
if(b>a || c>a)
{

    if(b!=0 && c!=0 && a>0)
    {

        if(c==2)
            nr=nr+a+b+c;
        else
            nr=nr+3;

    }
    else
        if(a==0 && c>0 && c>0)
            nr=nr+2;
    else

        nr++;

}
else

    if(a==b || a==c )
        if(b!=c)
        if(b==0 )
            nr=nr+3;
        else
            nr=nr+a+b+c;

printf("%I64d",nr);

    return 0;
}

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

long long a ,b,c,mini,nr;

int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&c);
if(a>3 || b>2 || c>2)
{

mini=a/3;
if(b/2 <mini)
    mini=b/2;
if(c/2 <mini)
    mini=c/2;
}

a=a-3*mini;
b=b-2*mini;
c=c-2*mini;
nr=mini*7;
if(a>3)
    a=3;
if(b>2)
    b=2;
if(c>2)
    c=2;

if(a==b && b==c)
    nr=nr+a+b+c;
if(a>b && a>c)
{
    if(b==0 && c==0)
        nr=nr+2;
        else
    if(b==c)
        nr=nr+a+b+c;
    else
    {
        if(b!=0 && c!=0)
            nr=nr+6;
        else
        {
            if(a==2)
                if(c==1)
                  nr=nr+3;
                else
                    if(b==1)
                        nr=nr+3;
            if(a==3)
            {
                if(b>0)
                    nr=nr+b+2;
                if(c>0)
                    nr=nr+c+1;
                }
        }
    }

}
else
if(b>a || c>a)
{

    if(b!=0 && c!=0 && a>0)
    {

        if(c==2)
            nr=nr+a+b+c;
        else
            nr=nr+3;

    }
    else
        if(a==0 && c>0 && c>0)
            nr=nr+2;
    else

        nr++;

}
else

    if(a==b || a==c )
        if(b!=c)
        if(b==0 )
            nr=nr+3;
        else
            nr=nr+a+b+c;

printf("%I64d",nr);

    return 0;
}

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

long long a ,b,c,mini,nr;

int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&c);
mini=a/3;
if(b/2 <mini)
    mini=b/2;
if(c/2 <mini)
    mini=c/2;
if(mini>1)
{

a=a-3*mini;
b=b-2*mini;
c=c-2*mini;
nr=mini*7;
}
if(a>3)
    a=3;
if(b>2)
    b=2;
if(c>2)
    c=2;

if(a==b && b==c)
    nr=nr+a+b+c;
if(a>b && a>c)
{
    if(b==0 && c==0)
        nr=nr+2;
        else
    if(b==c)
        nr=nr+a+b+c;
    else
    {
        if(b!=0 && c!=0)
            nr=nr+6;
        else
        {
            if(a==2)
                if(c==1)
                  nr=nr+3;
                else
                    if(b==1)
                        nr=nr+3;
            if(a==3)
            {
                if(b>0)
                    nr=nr+b+2;
                if(c>0)
                    nr=nr+c+1;
                }
        }
    }

}
else
if(b>a || c>a)
{

    if(b!=0 && c!=0 && a>0)
    {

        if(c==2)
            nr=nr+a+b+c;
        else
            nr=nr+3;

    }
    else
        if(a==0 && c>0 && c>0)
            nr=nr+2;
    else

        nr++;

}
else

    if(a==b || a==c)
        if(b==0 )
            nr=nr+3;
        else
            nr=nr+a+b+c;

printf("%I64d",nr);

    return 0;
}

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

long long a ,b,c,mini,nr;

int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&c);
mini=a/3;
if(b/2 <mini)
    mini=b/2;
if(c/2 <mini)
    mini=c/2;

a=a-3*mini;
b=b-2*mini;
c=c-2*mini;
if(a>3)
    a=3;
if(b>2)
    b=2;
if(c>2)
    c=2;
nr=mini*7;
if(a==b && b==c)
    nr=nr+a+b+c;
if(a>b && a>c)
{
    if(b==c)
        nr=nr+a+b+c;
    else
    {
        if(b!=0 && c!=0)
            nr=nr+6;
        else
        {
            if(a==2)
                if(c==1)
                  nr=nr+3;
                else
                    if(b==1)
                        nr=nr+3;
            if(a==3)
            {
                if(b>0)
                    nr=nr+b+2;
                if(c>0)
                    nr=nr+c+1;
                }
        }
    }

}
else
{if(b>a || c>a)
    if(b!=0 && c!=0 && a>0)
    {

        if(c==2)
            nr=nr+a+b+c;
        else
            nr=nr+3;

    }
    else
        if(a==0 && c>0 && c>0)
            nr=nr+2;
    else

        nr++;

}

printf("%I64d",nr);

    return 0;
}

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

long long a ,b,c,mini,nr;

int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&c);
mini=a/3;
if(b/2 <mini)
    mini=b/2;
if(c/2 <mini)
    mini=c/2;

a=a-3*mini;
b=b-2*mini;
c=c-2*mini;
if(a>3)
    a=3;
if(b>2)
    b=2;
if(c>2)
    c=2;
nr=mini*7;
if(a==b && b==c)
    nr=nr+a+b+c;
if(a>b && a>c)
{
    if(b==0 && c==0)
        nr=nr+2;
        else
    if(b==c)
        nr=nr+a+b+c;
    else
    {
        if(b!=0 && c!=0)
            nr=nr+6;
        else
        {
            if(a==2)
                if(c==1)
                  nr=nr+3;
                else
                    if(b==1)
                        nr=nr+3;
            if(a==3)
            {
                if(b>0)
                    nr=nr+b+2;
                if(c>0)
                    nr=nr+c+1;
                }
        }
    }

}
else
if(b>a || c>a)
{

    if(b!=0 && c!=0 && a>0)
    {

        if(c==2)
            nr=nr+a+b+c;
        else
            nr=nr+3;

    }
    else
        if(a==0 && c>0 && c>0)
            nr=nr+2;
    else

        nr++;
}
else
    if(a==b || a==c)
        if(b==0 )
            nr=nr+3;
        else
            nr=nr+a+b+c;

printf("%I64d",nr);

    return 0;
}

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

long long a ,b,c,mini,nr;

int main()
{
scanf("%I64d %I64d %I64d",&a,&b,&c);
if(a>3 || b>2 || c>2)
{

mini=a/3;
if(b/2 <mini)
    mini=b/2;
if(c/2 <mini)
    mini=c/2;
}

a=a-3*mini;
b=b-2*mini;
c=c-2*mini;
nr=mini*7;
if(a>3)
    a=3;
if(b>2)
    b=2;
if(c>2)
    c=2;

if(a==b && b==c)
    nr=nr+a+b+c;
if(a>b && a>c)
{
    if(b==0 && c==0)
        nr=nr+2;
        else
    if(b==c)
        nr=nr+a+b+c;
    else
    {
        if(b!=0 && c!=0)
            nr=nr+6;
        else
        {
            if(a==2)
                if(c==1)
                  nr=nr+3;
                else
                    if(b==1)
                        nr=nr+3;
            if(a==3)
            {
                if(b>0)
                    nr=nr+b+2;
                if(c>0)
                    nr=nr+c+1;
                }
        }
    }

}
else
if(b>a || c>a)
{

    if(a>0)
        if(b==0 || c==0)
        {

        if(b==0)
            nr=nr+3;
        if(c==0)
            nr=nr+2;

        }

     else
    if(b!=0 && c!=0 )
    {

        if(c==2)
            nr=nr+a+b+c;
        else
            nr=nr+3;

    }
    else
        if(a==0 && c>0 && b>0)
            nr=nr+2;
    else

        nr++;

}
else

    if(a==b || a==c )
        if(b!=c)
        if(b==0 )
            nr=nr+3;
        else
            nr=nr+a+b+c;

printf("%I64d",nr);

    return 0;
}


#include <stdio.h>

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

    for(int i=0;i<k;i++){
        if(n%10 == 0){
            n/=10;
        }
        else{
            n--;
        }
    }

    printf("%d",n); // beware of simple errors

}

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

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

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

#include <stdio.h>

int main(int argc, char const *argv[])
{
    /* code */
    long int n, k;
    scanf("%ld %ld", &n, &k);

    for(int i = 0; i < k; i++){
        if(n % 10 == 0)
            n = n / 10;
        else
            n--;
    }
    printf("%ld\n", n);
    return 0;
}

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

}

#include<stdio.h>
int main()
{
    int n,k,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>
int main()
{
    int num,k,i,count=0;
    scanf("%d%d",&num,&k);
    for(i=1;i<=k;i++)
    {
        if((num%10)==0)
        {
            num/=10;

        }
       else
        {
            num--;

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

#include<stdio.h>
int main()
{
    long long int a,k,num,c;
    scanf("%I64d %I64d",&a,&k);
    while(k--){
    if(a%10==0){
        num=a/10;
        a=num;
    }
   else if(a%10!=0)
    {
        num=a-1;
        a=num;
    }
    }
    printf("%I64d",num);
    return 0;
}

#include <stdio.h>
int main ()
{
    long long int i,a,b;
    scanf("%lld %lld",&a,&b);
    for(i =0; i<b;i++){
        if((a % 10)!= 0){
            a = (a-1);
            continue;

        }
        if((a%10)==0){
            a = (a/10);
        }
    }

    printf("%lld",a);

    return 0;
}

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

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

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

#include<stdio.h>
#include<math.h>
int main()
{
	int number,times;
	scanf("%d",&number);
	scanf("%d",&times);
	int k;
	int temp;
	int temp2;
	for(k=0;k<times;k++)
	{
		if(number>=0)
		{
			if(number%10==0)
			{
				number=number/10;
			}
			else
			{
				number=number-1;
			}
		}
		else
		{
			break;
		}
	}
	printf("%d",number);
}

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

int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    while(k>0)
    {
        if(n%10>0)
        {
            n=n-1;
            k--;
            continue;
        }
        else
        {
            n=n/10;
            k--;
            continue;
        }
    }
    printf("%d",n);
    return 0;
}

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

}

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

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

}

#include <stdio.h>

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

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

	// your code goes here
	return 0;
}

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

#include<stdio.h>

int main()
{
    long long int a,k,n;
    scanf("%I64d %I64d",&a,&k);
    while(k--)
    {
        if(a%10==0)
        {
            n=a/10;
            a=n;
        }
        else if(a%10!=0)
        {
            n=a-1;
            a=n;
        }
    }
    printf("%I64d",n);
    return 0;
}

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

	return 0;
}

#include<stdio.h>
int main()
{
    int n,i,k;
    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",n);

    return 0;

}

#include <stdio.h>

int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i = 0;i < k;i++){
        if(n == 0){
            break;
        }
        if(n%10 == 0){
            n = n/10;
        }
        else{
            n--;
        }
    }
    printf("%d",n);
    return 0;
}

#include<stdio.h>
int main()
{
int n,k;
scanf("%d%d",&n,&k);
while(k)
{
if(n%10!=0)
n=n-1;
else
n=n/10;
k--;

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

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

#include <stdio.h>

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    while(k--) {
        if(n % 10 == 0) {
            n /= 10;
        } else {
            --n;
        }
    }
    printf("%d\n", n);
    return 0;
}

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

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

    while(k--)
    {
        if(n%10!=0)
        {
        n--;
        }
        else
        {
            n/=10;
        }

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

#include<stdio.h>

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

          while(k!=0)
          {
               if(n%10!=0)
               n=n-1;

               else if(n%10==0)
               n=n/10;

               k--;
          }
          printf("%d",n);
}

#include <stdio.h>

int main()
{
    long n;
    int k;

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

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

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

#include<stdio.h>
int main()
{
    int n,k,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>
int main()
{
    int n,k,i=0,p;
    scanf("%d %d",&n,&k);
    for(i=0;i<k;i++)
    {
        if(n%10!=0)
        {
            n=n-1;
        }
        else
        {
        n=n/10;
        }
    }
    printf("%d",n);
    return 0;
}

#include <stdio.h>

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

}

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

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

}

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

int main() {

	int n, k, t;

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

	for (int i = 0; i < k; i++) {
		t = n % 10;

		if (t != 0) {
			n = n - 1;
		}
		else {
			n = n / 10;
		}
	}

	printf("%d", n);

	return 0;
}

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

#include<stdio.h>

int main()
{
  long int n;
  int k;
  scanf("%li",&n);
  scanf("%d",&k);
  while((k>0)&&(n>=0))
  {
    if(n%10==0)
    {
      n=n/10;
      k--;
    }
    else
    {
      n--;
      k--;
    }
  }
  printf("%li",n);
  return 0;
}

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

}

#include<stdio.h>

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

    int last_digit =0;
   while(b != 0)
   {

       last_digit = a % 10;
       if(last_digit!=0)
       {

           a = a-1;
       }
       else
       {
           a = a/10;
       }

       b--;

   }

printf("%ld\n",a);

return 0;

}

#include<stdio.h>

int main(){
    long n;
    int k;

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

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

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

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

#include <stdio.h>

int main()
{
    int n,c,i;
    scanf("%d %d", &n, &c);
    for (i=1; i<=c; i++)
    {
        if((n%10)!=0)
        {
             n--;

        }
        else
        {
            n/=10;

        }
    }

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

    return 0;
}

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

int main()
{   int n,k,x=0;
    scanf("%d %d",&n,&k);
    while(n>0&&x<k){
    if (n%10==0) n=n/10;
    else n--;
    x++;}
    printf("%d",n);
    return 0;
}

#include <stdio.h>

int main() {
   int n,k,i;
   scanf("%d %d",&n,&k);
   i=k;
   while(i>0) {
       if (n%10 == 0) {
           n = n/10;
           i--;
       }
       else {
           int t = n%10;
           if (t<=i) {
               n = n - t;
               i = i-t;
            }
           else {
               n = n-i;
               i = 0;
           }
       }
   }
   printf("%d",n);
   return 0;
}

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

}

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

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

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

#include <stdio.h>

int subtraction(int n, int k){
	while(k){
		if (n % 10 != 0)
			n--;
		else
			n /= 10;
        k--;
	}
	return n;
}

int main() {

	int n, k;
	scanf("%d %d", &n, &k);
	printf("%d", subtraction(n,k));
	return 0;
}

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

        }
        else n=n/10;
    }
    printf("%d",n);
    return 0;
}

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

#include<stdio.h>

int main()
{
    long int x;

    int y, i;

    scanf("%ld", &x);

    scanf("%d", &y);

    for(i=0; i<y; i++)
    {
        if(x%10 != 0)
        {
            x--;
        }
        else if(x%10 == 0)
        {
            x /= 10;
        }
    }

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

    return 0;
}

#include <stdio.h>

int main()
{
    int i, n, k;

    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", n);
    return 0;
}

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

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

#include<stdio.h>

int main()
{
    long long int k,i,n,r;
    scanf("%lld %lld",&n,&k);
    for(i=1;i<=k;i++)
    {
        r=n%10;
        if(r==0)
        {
            n/=10;
        }
        else
            n--;
    }
     printf("%lld\n",n);
    return 0;
}

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

        if(last!=0)
        {
            n=n-1;
        }
        else
        {
            n=n/10;
        }
    }
    printf("%d\n",n);
    return 0;
}

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

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

    for(;k>0;){
          j=n%10;
          if(k>j){
              n/=10;
              k-=j;
              k-=1;  }
          else{n-=k;
               k=0;}
                }
           printf("%d",n);
           return 0;

}

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

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

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

#include<stdio.h>

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

    int count=0;
    int temp=n;
    while(1) {
        if(temp%10==0) {
            temp=temp/10;
        }
        else {
            temp=temp-1;
        }
        count++;
        if(count==k) {
            break;
        }
    }
    printf("%d\n",temp);
    return 0;
}

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

}

#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <math.h>
int main()
{
	long long int n,k,mod,j=0,i;
	scanf("%lld%lld",&n,&k);
	for(i=1;i<=k;i++){
		mod=n%10;
		if(mod==0){
			n/=10;
		}
		else{
			n--;
		}
	}
	printf("%lld",n);
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main()
{int a,b;
scanf("%d%d",&a,&b);
while(b--)
{
    if(a%10!=0)
        a=a-1;
    else
        a=a/10;
}
printf("%d\n",a);
    return 0;
}

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

#include<stdio.h>

int main()
{
    int i,n,p;
    scanf("%d %d",&n,&p);
    for(i=0;i<p;i++)
    {
        if(n%10==0)
        {
            n = n/10;
        }
        else
        {
            n--;
        }
    }
    printf("%d",n);
    return 0;
}

#include<stdio.h>
int main()
{
long int n,k,i;
scanf("%ld%ld",&n,&k);

for(i=0;i<k;i++)
{
    if(n%10==0&&n!=0)
        n = n/10;

    else
        n--;
}
printf("%ld",n);

return 0;
}

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

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

	while (k != 0){
		if (n % 10 == 0)
			n = n/10;
		else
			n=n-1;
		k-=1;
	}
	printf("%d",n);

}

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

#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
#include <complex.h>
#include <errno.h>
int n,m;

int main()
{
	scanf("%d %d",&n,&m);
	while (m--)
	{
		if (n%10) n--;
		else n/=10;
	}
	printf("%d\n",n);
	return 0;
}

#include <stdio.h>

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    while(k--)
    {
        int rem=n%10;
        if(rem==0)
        n/=10;
        else
        n-=1;
    }
    printf("%d",n);
    return 0;
}

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

int main()
{
    int n,k,i;
    printf("enter the number you want to be subtracted");
    scanf("%d",&n);
    printf("how many times do you want to be subtracted tanya ");
    scanf("%d",&k);
    for(k;k!=0;k--)
    {
        if (n%10==0)
        {
            n=n/10;
        }
        else
        {
            n--;
        }

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

int main()
{
    long n;
    int k;

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

    for(int i = 0; i < k; i++)
    {
        if(n%10 == 0)
        {
            n /= 10;
        }
        else
        {
            n -= 1;
        }
    }
    return n;
}

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

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

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

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

    printf("%d", n);
}

#include<stdio.h>

int main()
{

 int n,k,i;

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

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

        if(n%10==0)
        {
            n=n/10;

        }

        else
        {

            n--;

        }

    }

    return 0;
}

#include<stdio.h>

int main()
{

 int n,k,i;

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

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

        if(n%2==0)
        {
            n=n/10;

        }

        else
        {

            n--;

        }

    }

    printf("%d",n);

    return 0;
}

#include<stdio.h>
int main(void)
{
	long long int N;
	int k;
	scanf("%d %d",&N,&k);
	while(k--)
	{
		if(N%10==0)
		N/=10;
		else
		N--;
	}
	printf("%d",N);
}

/*Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm:

if the last digit of the number is non-zero, she decreases the number by one;
if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit).
You are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions.

It is guaranteed that the result will be positive integer number.

Input
The first line of the input contains two integer numbers n and k (2≤n≤10E9, 1≤k≤50) — the number from which Tanya will subtract and the number of subtractions correspondingly.

Output
Print one integer number — the result of the decreasing n by one k times.

It is guaranteed that the result will be positive integer number.
*/

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

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

    while (k!=0)
    {
        if ( n%10 != 0)
        {
        n=n-1;
        }
        else
            {
                n=n/10;
            }
    k--;

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

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

int main ()
{
    int x;
		int count=0;
		printf("Please Enter Number");
		scanf("%d",&x);
		while	(x>1)
		{		if	(x%10==0)
					{	x=x/10;;
					}
				else
					{x--;
					}
					count++;
		}
		printf("Count=%d",count);
    return 0;
}

#include <stdio.h>

int main(int argc, char const *argv[])
{
    /* code */
    long long n, k;
    scanf("%ld %ld", &n, &k);

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

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

}

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

int main()
{   int x;
    int count =0;
    x=512;

    while (x>0)
    {
        if (x%10 == 0)
        {
            x=x/10;
        }
        else
        {
            x--;
            count++;
        }
    }

    printf("The counter = %d",count);

    return 0;
}

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

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

#include<stdio.h>

int main()
{
    int n,k,i;
scanf("%d %d",&n,&k);
  for(i=1;i<=k;i++)
  {
  if(n%10==0)
  n=n/10;
  else if(n%10!=0)
  n--;
  }
  printf("the last value is %d",n);
    return 0;
}

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

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

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

}

#include<stdio.h>
int main () {
    int num,k,m;
    scanf("%d %d",&num,&k);
    m=num % 10;
    while (k--) {
     if (m == 0 ) {
        num=num / 10;
     }
     else{
         num--;
     }
    }
    printf("%d\n",num);
}

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

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

#include<stdio.h>
int main()
{
    int n,k,i=0;
    printf("n&f");
    scanf("%d%d",&n,&k);
    while(i<k)
    { if (n%10!=0){n=n-1;}
    else if (n%10==0){n=n/10;}
    printf("the no is %d ",n);
        i++;
    }
}

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

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

    if(k>0){
          j=n%10;
          if(k>j){
              n/=10;
              k-=j;
              k-=1;
                  }
          else{n-=k;
               k=0;}
                }
           printf("%d",n);
           return 0;

}

#include<stdio.h>

int wrongSubstraction ( int x, int z );

int main() {
    // wrongSubstraction(512, 4);
    // wrongSubstraction(1000000000, 9);
}

int wrongSubstraction(int n, int k) {

    while(k>0) {
        if(n%10!=0)
            n-=1;
        else
            n/=10;
        k--;
    }

    return n;
}

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

#include <stdio.h>

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

        while(k--){
            if(n%10 == 0){
                n= n / 10;
            }
            else{
                n = n - 1;
            }

        }
                            printf("%d",n);

	// your code goes here
	return 0;
}

#include<stdio.h>
int main()
{
    int n,temp,x,i,X,rem,count=0,p;
    scanf("%d %d",&x,&n);
    temp=x;
    for(i=1;i<=n;i++)
    {
        if(temp%10==0)
            break;
        if(temp%10!=0)
        {
            temp--;
            count++;
        }
    }
    printf("%d\n%d\n",temp,count);
    for(i=1;i<=n-count;i++)
    {
        if(temp%10!=0)
        {
            temp--;
        }
        if(i==n-count)
            break;
        if(temp%10==0)
        {
        rem=temp/10;
        temp=rem;
        }
    }
    printf("%d",temp);

    return 0;
}

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

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

#include <stdio.h>

int main(){
    long n,k;
    scanf("%l %l",&n,&k);
    while(k--){
        if(n%10==0)
        n = (n/10)-1;
        else
        n = n-1;
    }
    printf("%l",n);
    return 0;
}

#include <stdio.h>

int main (void){
    int k, n;

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

    while ( (n/10) != 0)
    if  (n % 10 == 0) {
        n /= 10;
    }
    else if( n % 10 != 0)
    {
        n--;
    }

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

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

    int n,k;
    int i;
    printf("input the positive integer number:");
    scanf("%d",&n);

    printf("input the number of substractions:");
    scanf("%d",&k);

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

#include<stdio.h>

int main()
{

 int n,k,i;

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

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

        if(n%10==0)
        {
            n=n/10;

        }

        else
        {

            n--;

        }

    }

    return 0;
}

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

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

    printf("%d", n);
}

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

    printf("enter n and k : ");
    scanf("%d %d", &n);

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

}

#include <stdio.h>

int main()
{
    long n;
    int k;

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

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

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

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

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

#include<stdio.h>
int main()
{
    int n,temp,x,i,X,rem,count=0,a,count1=0;
    scanf("%d %d",&x,&n);
    temp=x;
    for(i=1;i<=n;i++)
    {
        if(temp%10==0)
            break;
        if(temp%10!=0)
        {
            temp--;
            count++;
        }
    }
    a=n-count;
   // printf("%d\n",a);
    for(i=1;i<=a-1;i++)
    {
        if(temp%10!=0)
        {
            temp--;
            continue;
        }
        if(temp%10==0)
        {
        rem=temp/10;
        temp=rem;
        }
    }
    //printf("%d\n%d\n",temp,count);
    for(i=a;i<=a;i++)
    {
       if(temp%10!=0)
        {
            temp--;
            count1++;
        }
        if(count1==1)
            break;
        if(temp%10==0)
        {
        rem=temp/10;
        temp=rem;
        }
    }
    printf("%d",temp);

    return 0;
}

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

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

int main() {

	int n, k, t;

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

	for (int i = 0; i < k; i++) {
		t = n % 10;

		if (t != 0) {
			n = n - 1;
		}
		else {
			n = n / 10;
		}
	}

	printf("%d", n);

	return 0;
}

#include <stdio.h>

int main (void){
    int k, n;

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

    if (n % 10 != 0) {
        n /= 10;
    }
    else
    {
        n--;
    }

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

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

}

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

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

if(n%10==0)

  n=n/10,i++;

else

  n=n-1,i++;

}
printf("%d",&n);
}

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

int main()
{
	int n, k;
	printf("The number from which Tanya will substract is:");
	scanf("%d", &n);
	printf("The number of substractions is:");
	scanf("%d", &k);
	while (k != 0)
	{
		if (n % 10 != 0)
		{
			n -= 1;
		}
		else
		{
			n /= 10;
		}
		k--;
	}
	printf("%d", n);
	return 0;
}

#include<stdio.h>
int main(){
    int n,k;
    scanf("%lldd %lld",&n,&k);
    while(k--){
        if(n %10 == 0)
        n/=10;
        else
        n--;
    }
    printf("%lld",n);
    return 0;

}

#include <stdio.h>

int main(void) {
	// your code goes here

    int n,k;
    n<=(10^9)&&n>=2;
    k<=50&&k>=1;
    printf("Enter 2 numbers");
    scanf("%d%d",&n,&k);

    for(int i=0; i<n; i++)
     {
         if(n%10 !=0)
          {
              n=n-1;
          }
         else

           n=n/10;

      }

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

#include <stdio.h>
int main(void)
{
    int n,k,i;
    n=512;
    k=4;
    for (size_t i= 1; i < k+1; )
    {
        if ((n%10==9))
        {
            i=i-1;
            n=n/10;
            n=n+2;
        }
        else
        {
            i=i+1;
            n=n-1;
        }

    }
    printf("your finnal number n=%d",n);
    getchar();
    getchar();
    return 0;
}

#include<stdio.h>

int wrongSubstraction ( int x, int z );

int main() {
    wrongSubstraction(512, 4);
    wrongSubstraction(1000000000, 9);
    return 0;
}

int wrongSubstraction(int n, int k) {

    while(k>0) {
        if(n%10!=0)
            n-=1;
        else
            n/=10;
        k--;
    }

    return n;
}

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

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

#include <stdio.h>

int main(int argc, char const *argv[])
{
    /* code */
    long long n, k;
    scanf("%ld %ld", &n, &k);

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

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

#include<stdio.h>

int main()
{
  long long n;
  int k;
  scanf("%ll",&n);
  scanf("%d",&k);
  while((k>0)&&(n>=0))
  {
    if(n%10==0)
    {
      n=n/10;
      k--;
    }
    else
    {
      n--;
      k--;
    }
  }
  printf("%ll",n);
  return 0;
}

#include<stdio.h>
int main(void)
{
	long long int N;
	int k;
	scanf("%d %d",&N,&k);
	while(k--)
	{
		if(N%10==0)
		N/=10;
		else
		N--;
	}
	printf("%d",N);
}

#include <stdio.h>

int main(){
    long n;int k;
    scanf("%l %d",&n,&k);
    while(k--){
        if(n%10==0)
        n = (n/10)-1;
        else
        n = n-1;
    }
    printf("%l",n);
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main()
{int a,b;
scanf("%d%d",&a,&b);
while(b--)
{
    if(a%10==0)
        a=a-1;
    else
        a=(a/10)*10;
}
printf("%d\n",a);
    return 0;
}

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

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

}

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

#include<stdio.h>
int main()
{
    int n,k;
    printf("n&f");
    scanf("%d%d",&n,&k);
    while(k--)
    { if (n%10!=0){n=n-1;}
    else if (n%10==0){n=n/10;}
    printf("the no is %d ",n);}
}

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

#include<stdio.h>

int wrongSubstraction ( int x, int z );

int main() {
    int a, b;
    scanf("%d, %d", &a, &b);
    printf("%d", wrongSubstraction(a, b));
    return 0;
}

int wrongSubstraction(int n, int k) {

    while(k>0) {
        if(n%10!=0)
            n-=1;
        else
            n/=10;
        k--;
    }

    return n;
}

#include<stdio.h>

int main()
{

 int n,k,i;

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

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

        if(n%2==0)
        {
            n=n/10;

        }

        else
        {

            n--;

        }

    }

    return 0;
}

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

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

}

#include<stdio.h>
int main () {
    int num,k,m;
    scanf("%d %d",&num,&k);
    m=(num % 10);
    while (k--) {
     if (m == 0 ) {
        num=num / 10;
     }
     else{
         num--;
     }
    }
    printf("%d",num);
}

#include <stdio.h>

int main() {
	// your code goes here

    int n,k,t;
    n<=(10^9)&&n>=2;
    k<=50&&k>=1;
    printf("Enter 2 numbers");
    scanf("%d%d",&n,&k);

    for(int i=0; i<k; i++)
     {
         t=n%10;
         if(t==0)
          {
              n=n/10;
          }
         else

           n=n-1;

      }

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

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

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

   r=re(n,k);
    printf("%d",r);

}
int re(int n,int k)
{

    while(k>0&&n>1)
    {
    if((n%10)==0)
     return(re(n/10,k-1));
    else
    return(re(n-1,k-1));
    }
}

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

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

#include<stdio.h>
int main()
{
long int n,k,i;
scanf("%lli%lli",&n,&k);

for(i=0;i<k;i++)
{
    if(n%10==0&&n!=0)
        n = n/10;

    else
        n--;
}
printf("%lli",n);

return 0;
}

#include <stdio.h>

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

#include <stdio.h>

int main (void){
    int k, n;

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

    if (n % 10 != 0) {
        n /= 10;
    }
    else if( n % 10 == 0)
    {
        n--;
    }

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

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

}

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

}

#include <stdio.h>

int main() {
   int n,k,i;
   scanf("%d %d",&n,&k);
   i=k;
   while(i>0) {
       if (n%10 == 0) {
           n = n/10;
       }
       else {
           int t = n%10;
           if (t<=i) {
               n = n - t;
               i = i-t;
            }
           else {
               n = n-i;
               i = 0;
           }
       }
   }
}

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