Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2 percent. You can connect charger to a joystick only at the beginning of each minute. In one minute joystick either discharges by 2 percent (if not connected to a charger) or charges by 1 percent (if connected to a charger).Game continues while both joysticks have a positive charge. Hence, if at the beginning of minute some joystick is charged by 1 percent, it has to be connected to a charger, otherwise the game stops. If some joystick completely discharges (its charge turns to 0), the game also stops.Determine the maximum number of minutes that game can last. It is prohibited to pause the game, i. e. at each moment both joysticks should be enabled. It is allowed for joystick to be charged by more than 100 percent.

The first line of the input contains two positive integers a1 and a2 (1 ≤ a1, a2 ≤ 100), the initial charge level of first and second joystick respectively.

Output the only integer, the maximum number of minutes that the game can last. Game continues until some joystick is discharged.

NoteIn the first sample game lasts for 6 minute by using the following algorithm:  at the beginning of the first minute connect first joystick to the charger, by the end of this minute first joystick is at 4%, second is at 3%;  continue the game without changing charger, by the end of the second minute the first joystick is at 5%, second is at 1%;  at the beginning of the third minute connect second joystick to the charger, after this minute the first joystick is at 3%, the second one is at 2%;  continue the game without changing charger, by the end of the fourth minute first joystick is at 1%, second one is at 3%;  at the beginning of the fifth minute connect first joystick to the charger, after this minute the first joystick is at 2%, the second one is at 1%;  at the beginning of the sixth minute connect second joystick to the charger, after this minute the first joystick is at 0%, the second one is at 2%. After that the first joystick is completely discharged and the game is stopped.

#include <stdio.h>

int main(void)
{
		int arr[2], conn, count = 0;
		scanf("%d %d ", &arr[0], &arr[1]);

		conn = (arr[1] < arr[0]);

		while (arr[0] > 0 && arr[1] > 0 && (arr[0] > 1 || arr[1] > 1)){
				arr[conn] += 1;
				arr[1-conn] -= 2;
				count++;
				conn = (arr[1] < arr[0]);
		}

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

#include<stdio.h>
int main(){
	int a,b,plug;
	long long int time;
	scanf("%d%*c%d",&a,&b);
	plug=(a<b?1:2);
	time=0;
	while((a>0) && (b>0)){
	//	printf("%d %d \n",a,b);
	if(a==1 && b==1){
		break;
	}
		if(plug==1){
			a++;
			b=b-2;
		}
		else if(plug==2){
			b++;
			a=a-2;
		}
		time++;
		if(a<=2){
			plug=1;
		}
		else if(b<=2){
			plug=2;
		}
	}
	printf("%64Id",(time));
	return 0;
}

#include <stdio.h>

int main(void) {
  long a,b,count=0;
  scanf("%ld%ld",&a,&b);
  while(a>1 || b>1){
    if(a>b && b>0){
      b++;
      a -=2;
    }
    else if(a<=b && a>0){
      a++;
      b -=2;
    }
    else break;
    //printf("%ld %ld\n",a,b);
    count++;
  }
  printf("%ld\n",count);
  return 0;
}

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

    }
    while(1)
    {
        if(n==1 && m==1)
            break;

        n=n+1;
        m=m-2;
        count++;
        if(m==0)
            break;
       else if(m<=2)
        {
            while(1)
            {
                n=n-2;
                m=m+1;
                count++;
                if(n<=2)
                    break;
            }
            if(n==0)
                break;
        }

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

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a;
    int b;
    scanf("%d %d",&a,&b);
    int c=0;
    int min=0;
    if(a==1 && b==1)
    {
        printf("0");
        exit(0);
    }
    else if(a==2 && b==2)
    {
        printf("1");
        exit(0);
    }
    if(a<b)
    {
        c=0;
    }
    else
    {
        c=1;
    }
    while(a>0 && b>0)
    {
        if(c==0)
        {
            min++;
            a+=1;
            b-=2;
            if(b==1 || b==2)
            {
                c=1;
                continue;
            }
            else
            {
                continue;
            }
        }
        else if(c==1)
        {
            min++;
            a-=2;
            b+=1;
            if(a==1 || a==2)
            {
                c=0;
                continue;
            }
            else
            {
                continue;
            }
        }
    }
    printf("%d",min);
}

#include<stdio.h>
int Calc(int a, int b)
{
    int i,j;
    int static cnt = 1;

    i = ( a >= b ) ? a : b;
    j = ( a <= b ) ? a : b;

    if((j==1&&i==2)||(j==2&&i==2))
    {
        printf("%d",cnt);
        return 0;
    }
    else if(i==1&&j==1)
    {
        printf("0");
        return 0;
    }

    i = i - 2;
    a = i;
    j = j + 1;
    b = j;
    cnt++;

    Calc(a,b);
}

int main()
{
    int a,b,i,j;
    scanf("%d %d",&a,&b);

    Calc(a,b);

    return 0;
}

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

int main(void)
{
	int a1, a2, count = 0;
	scanf("%d %d", &a1, &a2);
	while(a1 > 0 && a2 > 0)
	{
		if(a1 > a2) { a2 += 1; a1 -=2; }
		else { a1 += 1; a2 -= 2; }
		count += 1;
	}
	if(a1 < 0 || a2 < 0)  count -= 1;
	printf("%d\n", count);
	return 0;
}

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

int checker(int a1,int a2){
    int max,min,x,maxxx=0;

if(a1>a2){

        max=a1; min=a2;
    }
     else {max=a2; min=a1;}
    for(;;){
      if(max<min){
          x=max;
          max=min;
          min=x;
      }
        maxxx++;
        min++;
        max=max-2;
       if(max==0){break;}
    }
    return(maxxx);
}

#include<stdio.h>
int main(void)
{
	int a,b,t,i=0;
	scanf("%d%d",&a,&b);
	int max,min;
	max=a>b?a:b;
	min=a<b?a:b;
	while(min>=1&&max>1)
	{
		i++;
		max=max-2;
		min=min+1;
		t=max;
	max=max>min?max:min;
	min=t>min?min:t;

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

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

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

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

int main()
{
	int a,b,ans=0;
	scanf("%d%d",&a,&b);
	while(1)
	{
		if(a<=0||b<=0)
			break;

		if(a<=b)
		{
			a+=1;
			b-=2;
		}
		else
		{
			a-=2;
			b+=1;

		}
		ans++;
	}
	if(a<0 || b<0)
		ans--;
	printf("%d\n",ans );
	return 0;
}

#include<stdio.h>
char min_char(int a,int b){
	if(a>b)
		return 'b';
	else
		return 'a';
}
int main(){
	int a,b,min=0;
	char ch = 'a';
	scanf("%d%d",&a,&b);

	if(a>b)
		ch = 'b';
	else
		ch = 'a';

	while(a>=1 && b>=1){
		ch = min_char(a,b);
		if(a==1 && b==1)
			break;

		if(a==1){
			a += 1;
			b -= 2;
			ch = 'a';
		}else if(b==1){
			a -= 2;
			b += 1;
			ch = 'b';
		}else if(ch=='a'){
			a += 1;
			b -= 2;
		}else if(ch=='b'){
			a -= 2;
			b += 1;
		}
		//printf("%d %d\n",a,b);
		min++;
	}
	printf("%d",min);
	return 0;
}

#include<stdio.h>
int compute(int, int, int (*)[200]);
int main(void){

	int count[200][200]={0};

	int a, b;
	scanf("%d%d",&a,&b);
    printf("%d\n",compute(a,b,count));

	return 0;
}

int compute(int a, int b, int (*count)[200]){
   int t = a>b?a:b;
   b = a+b-t;
   a = t;
   if( a < 0 || b < 0)
	   return 0;
   if(a <=2 && b <=2){
	   if ( a < 2 && b < 2)
		   return 0;
	   else
		   return count[a][b]=1;
   }

   if(count[a][b])
	   return count[a][b];
   int m = compute(a+1, b-2, count);
   int l = compute(a-2,b+1, count);

	return count[a][b] = 1+(m>l?m:l);
}

#include<stdio.h>
#include<conio.h>
main()
{
     int a,b;
     scanf("%d %d",&a,&b);
     int count=0;
     while(a>0&&b>0)
     {    if(a==1&&b==1)
          break;
          else if(a<3)
          {a=a+1;
          b=b-2;
          }
          else if(b<3)
          {a=a-2;
           b=b+1;

          }
          else if(a>b)
          {
               a=a+1;
               b=b-2;
          }
          else
          {
               a=a-2;
               b=b+1;
          }
          count++;
     }
     printf("%d",count);
}

#include <stdio.h>
#include <string.h>
int n,m;
int f[220][220];
int max(int a,int b)
{
	return a>b?a:b;
}
int dp(int x,int y)
{
	if(x<=0||y<=0||x+y<=2) return 0;
	if(f[x][y]>=0) return f[x][y];
	return f[x][y] = max(dp(x-2,y+1),dp(x+1,y-2))+1;
}
int main()
{
	int i,j;
	memset(f,-1,sizeof(f));
	scanf("%d%d",&n,&m);
	printf("%d",dp(n,m));
	return 0;
}

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

}

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

int main()
{
	  int stick1, stick2, i;
	  int count = 0;
	  int control = 1;
	  scanf("%d%d",&stick1, &stick2);
	  if(stick1 > stick2)
	  {
		  control = 0;
	  }
	  for(;;)
	  {
		  if(stick1 <= 0 || stick2 <= 0)break;
		  if(1 == control)
		  {
			  stick1++;
			  stick2 -= 2;
		  }
		  else
		  {
			  stick2++;
			  stick1 -= 2;
		  }
		  if(0 == control && stick1 < stick2 &&stick1 -2 <= 0 )
		  {
			  control = 1;
		  }
		  else if(1 == control && stick2 < stick1 &&stick2 - 2 <= 0)
	      {
			  control = 0;
		  }
		  if(stick1 >= 0 && stick2 >= 0)count++;

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

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

/*  AUTHOR:AKASH JAIN
*   USERNAME:akash19jain
*   DATE:27/07/2019
*/
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define SC1(x)          scanf("%lld",&x)
#define SC2(x,y)        scanf("%lld%lld",&x,&y)
#define SC3(x,y,z)      scanf("%lld%lld%lld",&x,&y,&z)
#define SCS(x)          scanf("\n%s", x)
#define PF1(x)          printf("%lld\n",x)
#define PF2(x,y)        printf("%lld %lld\n",x,y)
#define PF3(x,y,z)      printf("%lld %lld %lld\n",x,y,z)
#define REP(i,n)        for(long long i=0;i<(n);i++)
#define FOR(i,a,b)      for(long long i=(a);i<=(b);i++)
#define FORD(i,a,b)     for(long long i=(a);i>=(b);i--)
#define WHILE(n)		while(n--)
#define MEM(a, b)       memset(a, (b), sizeof(a))
#define ITOC(c)         ((char)(((int)'0')+c))
#define MID(s,e)        (s+(e-s)/2)
#define SZ(a)		    strlen(a)
#define MOD             1000000007
#define MAX             10000000005
#define MIN             -10000000005
#define PI              3.1415926535897932384626433832795
#define DEB(x)          printf("The value of \"%s\" is: %d\n",#x,x)
#define CASES           ll t;SC1(t);while(t--)
#define ABS(a)          ((a>0)?a:-(a))

const int INF = 1<<29;
typedef long long ll;
typedef unsigned long long ull;
#define FILEIO(name) \  freopen(name".in", "r", stdin); \   freopen(name".out", "w", stdout);
int cmp(const void * a,const void * b);
long long maxv(long long a,long long b);
long long minv(long long a,long long b);
long long gcd(long long u,long long v);

int main()
{
    ll a,b,ans=0;
    SC2(a,b);
    while(a>0 && b>0)
    {
        if(a<b && b>=2)
        {
            a++;
            b-=2;
        }
        else if(a>=2)
        {
            b++;
            a-=2;
        }
        else
        {
            break;
        }
        ans++;
    }
    PF1(ans);
}

//qsort(arr,n,sizeof(arr[0]),cmp);
int cmp (const void * a, const void * b)
{
    if( *(ll*)a - *(ll*)b < 0 ) return -1;
    if( *(ll*)a - *(ll*)b > 0 ) return 1;
        return 0;
}
long long maxv(long long a,long long b)
{
    if(a>b) return a;
        return b;
}
long long minv(long long a,long long b)
{
    if(a<b) return a;
        return b;
}
long long gcd(long long u,long long v)
{
    if (v == 0) return u;
       return gcd(v, u%v);
}

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

	while(a>0 && b>0)
	{
		if(a==1 && b==1)
			break;
		if(a>b)
		{
			b+=1;a-=2;
		}
		else
		{
			a+=1;b-=2;}
		count++;
	}
	printf("%d\n",count-1);
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
int t1,t2,i,j,temp,ct=0;
scanf("%d %d",&t1,&t2);
if(t1<=t2){
i=t1;j=t2;}
else{
i=t2;j=t1;}
if(i<2&&j<2)
    printf("0");
else{
while(j>0)
{
ct++;
i++;j=j-2;
if(j==1||j==2||i==100){

temp=j;j=i;
i=temp;}}
printf("%d",ct);}
return 0;
}

/*
By Syed Rifat Raiyan
IUT CSE-18
I am a beacon of knowledge blazing out across a black sea of ignorance.
*/
#include<stdio.h>
#define SWAP(a,b) {a=a+b; b=a-b; a=a-b;}
int main()
{
    int a1,a2,i,j,mins=0;
    scanf("%d %d",&a1,&a2);
    if(a1==1 && a2==1)
    {
        printf("0");
        return 0;//weeew -_-
    }
    while(a1>0 && a2>0)
    {
    if(a1>a2)
    {
        SWAP(a1,a2);
    }
        a1++;
        a2-=2;
        mins++;
    }
    printf("%d",mins);
    return  0;
}

#include <stdio.h>

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

int main(){
    int ans = 0, a, b;
    scanf("%d%d", &a, &b);
    while(min(a, b) > 0){
        if(a < b){
            a += 1; b -= 2;
        }
        else{
            b += 1; a -= 2;
        }
        if(min(a, b) < 0) break;
        ans++;
    }
    printf("%d\n", ans);
}

#include<stdio.h>
int maxx(int a,int b)
{
return (a>b)?a:b;
}
int minn(int a,int b)
{
return (a<b)?a:b;
}
int main()
{
    int a, b,min=0;
    scanf("%d%d",&a,&b);
    if(a==b)
    {
    if(a==1)
    printf("0");
    else
    printf("%d",((a-2)*2)+1);
    }
    else
    {
    int aa=maxx(a,b);
    int bb=minn(a,b);
    int f=0,cnt=0;

    while(f==0)
    {
   // printf("%d %d\n",aa,bb);
    if(aa<=0||bb<=0||(aa==1&&bb==1))
    {
    f=1;
    break;
    }
    else
    {
    if(aa>bb)
    {
    aa-=2;
    bb++;
    cnt++;
    }
    else if(bb>aa)
    {
    bb-=2;
    aa++;
    cnt++;
    }
    else
    {
    cnt+=((aa-2)*2)+1;
    break;
    }
    }
    }
    printf("%d",cnt);
    }
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main() {

	int a1, a2;
	int res = 0;
	int d;
	int *pc, *pf, *t;

	scanf("%d%d", &a1, &a2);

	pf = &a1; pc = &a2;
	while (a1 > 2 || a2 > 2) {
		d = (*pf - 1) / 2;
		res += d;
		*pf -= 2 * d;
		*pc += d;
		t = pc; pc = pf; pf = t;
	}

	if (a1 == 2 || a2 == 2)
		res++;
	printf("%d", res);

}

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

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

int find(int x, int y) {
	int m = x, n = y, num = 0;
	if(m == 1 && n == 1) {
		return 0;
	}
	while(m > 0 && n > 0) {
		if(m > n) {
			m = m - 2;
			n = n + 1;
			num++;
		}
		else {
			m = m + 1;
			n = n - 2;
			num++;
		}
	}
	return num;
}

int main() {
	int a1, a2, result;
	scanf("%d%d", &a1, &a2);
	result = find(a1, a2);
	printf("%d", result);
	return 0;
}

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

int num=0;

void dian(int a,int b)
{
	num++;
	if(a*b==2||a==2&&b==2)
	{
		return;
	}
	if(a==1&&b==1)
	{
		num--;
		return;
	}
	dian(a>b?(a-2):(a+1),a>b?(b+1):(b-2));

}

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

#include<stdio.h>

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

    printf("%d\n",a+b-2-c);
    }
    return 0;
}

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

int main(){
	int a,b,i,count = 0;
	scanf("%d %d",&a,&b);
	while(a>0 && b>0){
		if(a==1 && b==1){
			break;
		}

		if(a<b)
		{
			a++;
			b -= 2;
			count++;
		}
		else if(a>=b){
			b++;
			a-=2;
			count++;
		}
	}
	printf("%d\n",count);

	return 0 ;
}

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

int main(int argc, char const *argv[])
{
	int a1, a2, t = 0;
	scanf("%d %d",&a1,&a2);

	while(a1 > 0 && a2 > 0)
	{
		if(a1 <= 1 && a2 <= 1)
		{
			break;
		}
		else if(a1 < a2)
		{
			a1 = a1 + 1;
			a2 = a2 - 2;
		}
		else
		{
			a1 = a1 - 2;
			a2 = a2 + 1;
		}
		++t;
	}
	printf("%d\n", t);
	return 0;
}

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

#include <stdio.h>

int main()
{
    int a,b,i,j,cnt=0,temp,mx,mn;
    scanf("%d %d",&a,&b);

    if(a<2 && b<2) {
        printf("0");
        return 0;
    }

    if(a<b) {
        mx = b;
        mn = a;
    }
    else {
        mx = a;
        mn = b;
    }

    for(i=1; ;i++) {
        cnt++;
        mn = mn+1;
        mx = mx-2;
        if(mx == 1 || mx == 2) {
            temp = mn;
            mn = mx;
            mx = temp;
        }
        if(mx == 0)
            break;

    }

    printf("%d",cnt);

}

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

#define MAX 10005

typedef long long ll;

char temp[MAX];
int i, j;

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

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

int a, b, dp[105][105];

int solve(int x, int y, int sum){
    if(y <= 0 || x <= 0) return sum;

    if(dp[x][y] + 1) return dp[x][y];
    dp[x][y] = 0;

    int solve1 = sum, solve2 = sum;

    if(x >= 2) solve1 = solve(x - 2, y + 1, sum + 1);
    if(y >= 2) solve2 = solve(x + 1, y - 2, sum + 1);

    return dp[x][y] = max(solve1, solve2);
}

int main(){

    int a, b; scanf("%d%d", &a, &b);
    memset(dp, -1, sizeof(dp));

    printf("%d", solve(a, b, 0));

    return 0;
}

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

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

#include<stdio.h>

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    int count=0;
    if(a==1&&b==1){printf("%d",count); return 0;}

    for(;;)
    {
       // printf("%d %d\n",a,b);
        if(a<=b){a=a+1;b=b-2;if(b<1){break;} count=count+1;continue;}
        if(b<=a){b=b+1;a=a-2;if(a<1){break;}  count=count+1;continue;}

    }
    printf("%d",count+1);
    return 0;
}

#include<stdio.h>
int min(int x,int y)
{
    if(x>y)
    return y;
    else
    return x;
}
int max(int x,int y)
{
    if(x<y)
    return y;
    else
    return x;
}
/*int game(int a1,int a2)
{
    if(a1==0||a2==0)
    return 0;
    else
    {
        if(a1>=2&&a2<2)
        return 1+game(min(a1-2,a2+1),max(a1-2,a2+1));
        else if(a2>=2&&a1<2)
        return 1+game(min(a1+1,a2-2),max(a1+1,a2-2));
        else if(a1>=2&&a2>=2)
        {if(1+game(min(a1-2,a2+1),max(a1-2,a2+1))>1+game(min(a1+1,a2-2),max(a1+1,a2-2)))
        return 1+game(min(a1-2,a2+1),max(a1-2,a2+1));
        else
        return 1+game(min(a1+1,a2-2),max(a1+1,a2-2));}
    }
}*/
int game(int a1,int a2)
{
    if(a1==0||a2==0)
    return 0;
    if(a1<2&&a2<2)
    return 0;
    else
    return 1+game(min(a1+1,a2-2),max(a1+1,a2-2));
}
int main()
{
    int a1,a2,a[101][101],i,j;
    scanf("%d %d",&a1,&a2);
    printf("%d",game(min(a1,a2),max(a1,a2)));
}

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

int main() {

	int first_joystick, second_joystick, result;

	scanf("%i %i", &first_joystick, &second_joystick);

	if ( (first_joystick-second_joystick)%3 == 0)
		result = first_joystick+second_joystick-3;
	else
		result = first_joystick+second_joystick-2;

	if(result < 0)
		result = 0;

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

	return 0;
}

#include <stdio.h>
int abs(int a) {
  return a>0?a:-a;
}
int min(int a, int b) {
  return a<b?a:b;
}
int main(void) {
  int a,b;
  scanf("%d%d",&a,&b);
  if (a+b==2) printf("0\n");
  else if ((a-b)%3==0)
    printf("%d\n",(min(a,b)+abs(a-b)/3-2)*2+1+abs(a-b)/3);
  else printf("%d\n",abs(a-b)/3+abs(a-b)%3+(min(a,b)+abs(a-b)/3-1)*2);
  return 0;
}

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

int main(void)
{
  int a[2];
  int i, j, k;
  int count;

  scanf("%d %d", &a[0], &a[1]);

  count = 0;
  i = (a[0] < a[1]) ? 0 : 1;
  j = (i == 0) ? 1 : 0;
  if (a[i] == 1 && a[j] == 1) goto out;
  while (a[0] >= 1 && a[1] >= 1) {
    a[i] += 1;
    a[j] -= 2;
    if (a[j] <= 2) {
      k = i;
      i = j;
      j = k;
    }
    count++;
   // printf("%d %d\n", a[i], a[j]);
  }
out:
  printf("%d\n", count);

  return 0;
}

#include<stdio.h>

	int main ()
{
	int a,b,count=0;
	scanf("%d%d",&a,&b);
	while(a>0  &&  b>0)
	{
		if(a>b)
		{
			b++;
			a=a-2;
			if(a>=0)
			count++;

		}
		else
		{
			a++;
			b=b-2;
			if(b>=0)
			count++;
		}
	}
	printf("%d",count);

}

#include<stdio.h>

int main(void){
	int a,b,i;

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

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

		if(a<=b) {
			a=a+1;
			b=b-2;
		}
		else {
			b=b+1;
			a=a-2;
		}
		if(a<=0||b<=0) break;
	}
	if(a==0||b==0) printf("%d\n",i+1);
	else printf("%d",i);

return 0;
}

#include <stdio.h>
typedef struct Stick{
                        short a1, a2, Max;
                        void (*Inite)(struct Stick*);
                        void (*MaxDurationGame)(struct Stick*);
                        void (*DispalyMs)(struct Stick*);
}Stick;
void Inite(Stick*);
void MaxDurationGame(Stick*);
void DispalyMs(Stick*);
int main()
{
    Stick s;
    s.Inite = Inite, s.Inite(&s), s.MaxDurationGame(&s), s.DispalyMs(&s);

    return 0;
}
void Inite(Stick* s){
    s->DispalyMs = DispalyMs, s->MaxDurationGame = MaxDurationGame, s->Max = 0;
    scanf("%hd%hd", &s->a1, &s->a2);
}
void MaxDurationGame(Stick* s){
    while(s->a1 > 0 && s->a2 > 0){
        if(1 == s->a1 && 1 == s->a2){ break; }
        if(s->a1 > s->a2){ s->a1 -= 2, s->a2 += 1; }
        else{ s->a2 -= 2, s->a1 += 1; }
        s->Max++;
    }
}
void DispalyMs(Stick* s){
    printf("%hd", s->Max);
}

#include<stdio.h>
int main()
{
    int a1,a2,x=0;          //有两个操纵杆，只有一个充电器一次能充1%的电，不充电的操纵杆掉2%的电
    scanf("%d%d",&a1,&a2); //输入起始电源
    while(a1>0&&a2>0)
    {
        if(a1==1&&a2==1)           //等于1的时候游戏一分钟也不能玩下去
        {
            break;
        }
        if(a1<a2)
        {
            a2-=2;
            a1+=1;
            x++;
        }
        else
        {
            a1-=2;
            a2+=1;
            x++;
        }

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

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

int main(void)
{
	int a1, a2, count = 0;
	scanf("%d %d", &a1, &a2);
	while(a1 > 0 && a2 > 0)
	{
		if(a1 > a2) { a2 += 1; a1 -=2; }
		else { a1 += 1; a2 -= 2; }
		count += 1;
	}
	if(a1 < 0 || a2 < 0)  count -= 1;
	printf("%d\n", count);
	return 0;
}

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

int f[200][200];

int res(int a, int b){
    if (f[a][b] > 0 && a > 0 && b > 0)
        return f[a][b];
    if (a <= 0) return 0;
    if (b <= 0) return 0;
    if (a <= 1 && b <= 1) return 0;
    f[a][b] = max(res(a-2,b+1), res(a+1,b-2))+1;
    return f[a][b];
}

int main(){
    int a,b;
    int i, j;
    scanf("%d %d", &a, &b);
    for (i = 0; i <= 200; i++)
        for (j = 0; j <= 200; j++)
            f[i][j] = 0;
    printf("%d", res(a,b));
    return 0;
}

#include "stdio.h"

#define BASE "%d"
typedef int Base;

typedef struct UJoystick
{
    Base Charge;
} UJoystick;

int main()
{
    Base GameTime = 0;
    UJoystick FirstJoystick;
    UJoystick SecondJoystick;
    scanf(BASE BASE, &FirstJoystick.Charge, &SecondJoystick.Charge);

    if (FirstJoystick.Charge == (SecondJoystick.Charge == 1))
    {
        printf(BASE"\n", 0);
        return 0;
    }

    while (FirstJoystick.Charge && SecondJoystick.Charge)
    {
        GameTime++;

        if (FirstJoystick.Charge < SecondJoystick.Charge)
        {
            FirstJoystick.Charge++;
            SecondJoystick.Charge -= 2;
        }
        else
        {
            FirstJoystick.Charge -= 2;
            SecondJoystick.Charge++;
        }
    }

    printf(BASE"\n", GameTime);
    return 0;
}

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

	while(a>0 && b>0)
	{
		if(a==1 && b==1)
			break;
		if(a>b)
		{
			b+=1;a-=2;
		}
		else
		{
			a+=1;b-=2;}
		count++;
	}
	printf("%d\n",count-1);
}

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

#define pf printf
#define sf scanf

int main(void){
 //   int n;
//  sf("%d", &n);
 //   int arr[n];
//    for(int i=0;i<n; i++) sf("%d", &arr[i]);

    int a1, a2;
    sf("%d %d", &a1, &a2);
    int mins = 0;
    char c = a1<=2 ? 0 : 1;
    while(a1 > 0 && a2 > 0){
        if(c == 0){
            a1 += 1;
            a2 -=2;
            if(a2 <=2 ) c=1;
        }
        else {
            a2 +=1;
            a1-=2;
            if(a1<=2) c=0;
        }
        mins++;
    }// while
    pf("%d\n", mins);
    return 0;
} //main

#include <stdio.h>
#include <stdlib.h>
int main(void) {
	int p,q,M,N,AIDE,t=0;
	scanf("%d %d",&p,&q);
	if(p<q){
		N = p;
		M = q;
	}else{
		N = q;
		M = p;
	}
	while(M > 0 ){
		M -= 2;
		N += 1;
		if(M==1 || M==2){
			AIDE=M;
			M = N;
			N = AIDE;
		}
		t++;
	}
	printf("%d", t );
	return 0;

}

#include <stdio.h>

int main()
{
	int i,j,a1,a2,c,nc,*min,*max,*temp,t=0;
	scanf("%d %d",&a1,&a2);
	if(a1<=a2)
	{
		min=&a1;
		max=&a2;
	}
	else
	{
		min=&a2;
		max=&a1;
	}
	//printf("%d %d\n",*min,*max);
	if(a1==a2 && a1==2)
	{
		printf("1\n");
		return 0;
	}
	while(*min>0 && *max>0)
	{
		t++;
		(*min)=(*min)+1;
		(*max)=(*max)-2;
		//printf("%d %d\n",a1,a2);

		if((*max)==1 || (*max)==2)
		{
			temp=min;
			min=max;
			max=temp;
		}
	}
	printf("%d\n",t);
	return 0;
}

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

int find(int x, int y) {
	int m = x, n = y, num = 0;
	if(m == 1 && n == 1) {
		return 0;
	}
	if(m == 100 && n == 100) {
		num--;
	}
	while(m > 0 && n > 0) {
		if(m > n) {
			m = m - 2;
			n = n + 1;
			num++;
		}
		else {
			m = m + 1;
			n = n - 2;
			num++;
		}
	}
	return num;
}

int main() {
	int a1, a2, result;
	scanf("%d%d", &a1, &a2);
	result = find(a1, a2);
	printf("%d", result);
	return 0;
}

#include<stdio.h>

	int main ()
{
	int a,b,count=0;
	scanf("%d%d",&a,&b);
	while(a!=0  &&  b!=0)
	{
		if(a>b)
		{
			b++;
			a=a-2;
			count++;

		}
		else
		{
			a++;
			b=b-2;
			count++;
		}
	}
	printf("%d",count);

}

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

int main(void) {
	int a1, a2, ukupno = 0;
	scanf("%d%d", &a1, &a2);
	while (a1 != 0 && a2 != 0){
	 	if (a1 == 1 && a2 == 1) {
			a1++;
			a2++;
		}
		else {
			if (a1 > a2) {
				a2++;
				a1 -= 2;
			}
			else {
				a1++;
				a2 -= 2;
			}
		}
		ukupno++;
	}
	printf("%d", ukupno);

	return 0;
}

#include<stdio.h>
int main()
{
    int p,q,sum=0;
    scanf("%d %d",&p,&q);
    while(p!=0&&q!=0)
    {
        if(p>q)
        {
            p=p-2;
            q=++q;
        }
        else
        {
            q=q-2;
            p=++p;
        }
        ++sum;
    }
    printf("\n%d",sum);
    return 0;
}

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

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main() {

	int a1, a2;
	int res = 0;
	int d;
	int *pc, *pf, *t;

	scanf("%d%d", &a1, &a2);

	pf = &a1; pc = &a2;
	while (a1 > 2 || a2 > 2) {
		d = (*pf - 1) / 2;
		res += d;
		*pf -= 2 * d;
		*pc += d;
		t = pc; pc = pf; pf = t;
	}

	if (a1 >= 2 && a2 >= 2)
		res++;
	printf("%d", res);

}

#include<stdio.h>

int main(void)
{
    int count = 0, j1, j2;

    scanf("%d %d", &j1, &j2);

    while( (j1 > 0) && (j2 >0) ) {
        if( j1 > j2 ) j1-=2, ++j2;
        else ++j1, j2-=2;
        ++count;
    }

    printf("%d", count);

    return 0;
}

#include<stdio.h>
/*int max_time=0,dp[200][200];
void init()
{
	int i,j;
	for(i=0;i<=100;i++)
	{
		for(j=0;j<=100;j++)
		{
			dp[i][j]=-1;
		}
	}
}
int calc_time(int x,int y,int t)
{
	if(x<=0 || y<=0)
	{
		if(max_time<t)
		{
			max_time=t;
		}
		return max_time;
	}
	if(dp[x][y]!=-1)
	{
		return dp[x][y];
	}
	int y1 = calc_time(x+1,y-2,t+1);
	int z1 = calc_time(x-2,y+1,t+1);
	if(y1>z1)

	{
	return y1;
}
else
{
	return z1;
}
}*/
int main()
{
	int a1,a2,x;
	scanf("%d %d",&a1,&a2);
	//init();
	//int x=calc_time(a1,a2,0);
	if(a1!=a2)
	{
		x=(a1+a2)-2;
	}
	else
	{
		x=(a1+a2)-3;
	}
	printf("%d",x);
	return 0;
}

#include <stdio.h>

int Min(int n, int m)
{
    if(n<=m)
    return n;
    else
    return m;
};

int main()
{
    int n,m, count=0;
    scanf("%d %d", &n, &m);
    while(n>0 && m>0)
    {
        int temp=Min(n,m);
        if(temp==n)
        {
            n+=1;
            m-=2;
        }
        else
        {
            n-=2;
            m++;
        }
        count++;
    }
    printf("%d", count);
    return 0;
}

#include<stdio.h>
int main(){
	int a,b,plug;
	long long int time;
	scanf("%d%*c%d",&a,&b);
	plug=(a<b?1:2);
	time=0;
	while((a>0) && (b>0)){
	//	printf("%d %d \n",a,b);
		if(a<=2){
			plug=1;
		}
		else if(b<=2){
			plug=2;
		}
		if(plug==1){
			a++;
			b=b-2;
		}
		else if(plug==2){
			b++;
			a=a-2;
		}
		time++;
	}
	printf("%64Id",(time));
	return 0;
}

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

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

int main()
{
    int a1,a2,charge,i = 0;
    scanf("%d%d",&a1,&a2);
    charge = 1;
    while(a1 >= 1 && a2 >= 1)
    {
        if (a1 <= 2)
        {
            charge = 1;
        }
        else if (a2 <= 2)
        {
            charge = 0;
        }
        else if (a1 <= a2)
        {
            charge = 1;
        }
        if (charge)
        {
            a1 += 1;
            a2 -= 2;
        }
        else
        {
            a1 -= 2;
            a2 += 1;
        }
        i++;
    };
    printf("%d",i);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a;
    int b;
    scanf("%d %d",&a,&b);
    int c=0;
    int min=0;
    if(a<b)
    {
        c=0;
    }
    else
    {
        c=1;
    }
    while(a>0 && b>0)
    {
        if(c==0)
        {
            min++;
            a+=1;
            b-=2;
            if(b==1 || b==2)
            {
                c=1;
                continue;
            }
            else
            {
                continue;
            }
        }
        else if(c==1)
        {
            min++;
            a-=2;
            b+=1;
            if(a==1 || a==2)
            {
                c=0;
                continue;
            }
            else
            {
                continue;
            }
        }
    }
    printf("%d",min);
}

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

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

    int breaker=-1;
    int ind=1;
    int cnt=0;
    while(max!=0 && min !=0 && max!=100 && min!=100){
    if(max<=2 && min<=2)
    {
        breaker=1;
        break;
    }
    if(ind==1){
        while(min>2){
                max++;
                min-=2;
                cnt++;
        }
        ind=2;
    }
    else{
        while(max>2){
                min++;
                max-=2;
                cnt++;
        }
        ind=1;

    }

    }
    if(breaker==1)
        cnt++;
    printf("%d",cnt);

}

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

#include<stdio.h>
int main(){
	int a,b,plug;
	long long int time;
	scanf("%d%*c%d",&a,&b);
	plug=(a<b?1:2);
	time=0;
	while((a>0) && (b>0)){
	//	printf("%d %d \n",a,b);
		if(plug==1){
			a++;
			b=b-2;
		}
		else if(plug==2){
			b++;
			a=a-2;
		}
		time++;
		if(a<=2){
			plug=1;
		}
		else if(b<=2){
			plug=2;
		}
	}
	printf("%64Id",(time));
	return 0;
}

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

		if(flag==1)
		{
			a=a-2;
			b=b+1;
			if(a<=3)
			{
				flag=0;
			}
		}
		else
		{
			b=b-2;
			a=a+1;
			if(b<=3)
			{
				flag=1;
			}
		}
		count++;
	}
	printf("%d\n",count);
	return 0;
}

#include <stdio.h>

int main() {
	// your code goes here
	int a[2],time=1,min=0;
	scanf("%d",&a[0]);
	scanf("%d",&a[1]);

	if(a[0]<=a[1])
		min=0;
	else min=1;

	while(a[(min+1)%2]>2){
		a[min]=a[min]+1;
		a[(min+1)%2]=a[(min+1)%2]-2;
		time=time+1;
		if(a[(min+1)%2] <= 2)
			min=(min+1)%2;

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

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

int num=0;

void dian(int a,int b)
{
	num++;
	if(a==1&&b==1||a*b==2||a==2&&b==2)
	{
		return;
	}
	dian(a>b?(a-2):(a+1),a>b?(b+1):(b-2));

}

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

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

int main(int argc, char const *argv[])
{
	int a1, a2, t = 0;
	scanf("%d %d",&a1,&a2);

	while(a1 > 0 && a2 > 0)
	{
		if(a1 < a2)
		{
			a1 = a1 + 1;
			a2 = a2 - 2;
		}
		else
		{
			a1 = a1 - 2;
			a2 = a2 + 1;
		}
		++t;
	}
	printf("%d\n", t);
	return 0;
}

#include<stdio.h>

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    int count=0;
    for(;;)
    {
       // printf("%d %d\n",a,b);
        if(a<=b){a=a+1;b=b-2;if(b<1){break;} count=count+1;continue;}
        if(b<=a){b=b+1;a=a-2;if(a<1){break;}  count=count+1;continue;}

    }
    printf("%d",count+1);
    return 0;
}

#include<stdio.h>
int main(){
    int a,b,c,d;
    scanf("%d%d",&a,&b);
    if(a==100 && b==100){
    --b;}
    int max,min;
    max=a;
    if(b>a)
    {
        max=b; min =a;
    }
    else{
            max=a; min=b;}

    int breaker=-1;
    int ind=1;
    int cnt=0;
    while(max!=0 && min !=0){
    if(max<=2 && min<=2)
    {
        breaker=1;
        break;
    }
    if(ind==1){
        while(min>2 && max!=100){
                max++;
                min-=2;
                cnt++;
        }
        ind=2;
    }
    else{
        while(max>2 && min!=100){
                min++;
                max-=2;
                cnt++;
        }
        ind=1;

    }

    }
    if(breaker==1)
        cnt++;
    printf("%d",cnt);

}

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main() {

	int a1, a2;
	int res = 0;
	int d;
	int *pc, *pf, *t;

	scanf("%d%d", &a1, &a2);

	pf = &a1; pc = &a2;
	while (a1 > 2 || a2 > 2) {
		d = (*pf - 1) / 2;
		res += d;
		*pf -= 2 * d;
		*pc += d;
		t = pc; pc = pf; pf = t;
	}

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

}

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

int main(void) {
	int a1, a2;
	scanf("%d %d", &a1, &a2);
	int ukupno = 0;
	while (1){
		if (a1 == 0 || a2 == 0) break;
		else if (a1 == 1) {
			a1 ++;
			a2 -= 2;
		}
		else if (a1 == 1 && a2 == 1) {
			a1 = a2 = 2;
		}
		else if (a2 == 1){
			a2++;
			a1 -= 2;
		}
		else {
			if (a1 > a2) {
				a2++;
				a1 -= 2;
			}
			else {
				a1++;
				a2 -= 2;
			}
		}
		ukupno++;

	}
	printf("%d", ukupno);

	return 0;
}

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

int main(void) {
	int a1, a2;
	scanf("%d %d", &a1, &a2);
	int ukupno = 0;
	while (1){
		if (a1 == 0 || a2 == 0) break;
		else if (a1 == 1 && a2 == 1) {
			a1++;
			a2++;
		}
		else if (a1 == 1) {
			a1 ++;
			a2 -= 2;
		}
		else if (a2 == 1){
			a2++;
			a1 -= 2;
		}
		else {
			if (a1 > a2) {
				a2++;
				a1 -= 2;
			}
			else {
				a1++;
				a2 -= 2;
			}
		}
		ukupno++;

	}
	printf("%d", ukupno);

	return 0;
}

#include<stdio.h>

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

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

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

int main()
{
    int counter=0,chargeA,chargeB,i;
    scanf("%i%i",&chargeA,&chargeB);

    while(chargeA>0 && chargeB>0)
    {
        if(chargeA<=chargeB)
        {
            chargeA += 1;
            chargeB -= 2;
            ++counter;
        }

        else
        {
            chargeB += 1;
            chargeA -= 2;
            ++counter;
        }
    }

    printf("%i\n",counter);

    return 0;
}

#include<stdio.h>

int main()
{

    int c, nc, t = 0, ch;
    scanf("%d %d", &c, &nc);
    while(c > 0 || nc > 0)
    {

        if(nc < c)
        {

            ch = nc;
            nc = c;
            c = ch;
        }
        nc = nc - 2;
        c = c + 1;
        t = t + 1;
    }
    printf("%d\n", t - 3);
    return 0;
}

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

#include<stdio.h>
int xx(int a,int b)
{
if(a<0||b<=0)
return 0;
else
{
if(a>=b)
{
b+=1;
a-=2;
}
else
{
a+=1;
b-=2;
}
return 1+xx(a,b);
}

}

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

#include <stdio.h>
#include <math.h>
int max(int a,int b)
{
	if (a>b)return a;
	return b;
}
int min(int a,int b)
{
	if (a>b)return b;
	return a;
}
int main ()
{
	int a,b,c,d,x;
	scanf ("%d%d",&a,&b);
	c=max(a,b);
	d=min(a,b);
	x=(c-d)/3;
	c=c-2*x;
	d=d+x;
	if (c==d)
		x+=2*c-3;
	else if (fabs(a-b)==2)
		x+=2*min(c,d);
	else if (fabs(a-b)==1)
		x+=2*min (a,b)-1;
	printf ("%d\n",x);
}

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

/**
* I'm sorry I was an Idiot
*/
#include<stdio.h>

int main(){
	int a,b;
	scanf( "%d %d",&a,&b);
	if(b < a){
		int temp = a;
		a = b;
		b = temp;
	}
	int totalMin = 0;
	//int m = 0;
	while(1){
		if(a <= 2 && b <= 2){
			++totalMin;
			break;
		}
		int max = b >> 1;
		if(b % 2 == 0)
			--max;
		//printf("max es %d\n",max);
		totalMin += max;
		a += max;
		b -= (max) << 1;
		//printf("%d %d\n",a,b);
		int temp = a;
		a = b;
		b = temp;
		//++m;
	}
	printf("%d\n",totalMin);
	return 0;
}

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

#include<stdio.h>
int main(void){
	int lista[220][2],listb[220][2];
	scanf("%d %d",&lista[0][0],&listb[0][0]);
	int time=0;
	int num[2]={1,0};
	int flag=0;
	for (;num[flag];time++){
		int oppo=1-flag;
		num[oppo]=0;
		for (int i=0;i<num[flag];i++){
			int x=lista[i][flag];
			int y=listb[i][flag];
			if (y-2>0){
				int appear=0;
				for (int j=0;j<num[oppo];j++){
					if (lista[j][oppo]==x+1&&listb[j][oppo]==y-2){
						appear=1;
						break;
					}
				}
				if (!appear){
					lista[num[oppo]][oppo]=x+1;
					listb[num[oppo]++][oppo]=y-2;
				}
			}
			if (x-2>0){
				int appear=0;
				for (int j=0;j<num[oppo];j++){
					if (lista[j][oppo]==x-2&&listb[j][oppo]==y+1){
						appear=1;
						break;
					}
				}
				if (!appear){
					lista[num[oppo]][oppo]=x-2;
					listb[num[oppo]++][oppo]=y+1;
				}
			}
		}
		flag=oppo;
	}
	printf("%d",time);
}

#include<stdio.h>
int main()
{
    int a , b , min , max ;

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

    min = a > b ? b : a ;

    max = a+b-min ;
    b = 0 ;
    while(min > 0 && max > 0)
    {
        max -= 2;
        min++ ;
        if(max <= 0)break;
        b++;
        if(min > max){
            a = min ;
            min = max ;
            max = a ;
        }
    }
    printf("%d",b);
    return 0 ;

}

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

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

    int a,b;
    long long min = 0;

    scanf("%d %d",&a,&b);
    if(a == 1 && b == 1)
        printf("0");
    else
    while(a > 0 && b > 0){
        if(a == 1 || a == 2){
            a = a + 1;
            b = b - 2;
        }
        else{
            b = b + 1;
            a = a - 2;
        }

        min = (long long)(min + 1);

    printf("%I64d",min);
    }
}

#include <stdio.h>
#include <stdlib.h>
int memo[101][101];
void init(){
	int i=0,j=0;
	for(i=0;i<101;i++){
		for(j=0;j<101;j++){
			memo[i][j] = -1;
		}
	}
}
int max(int a,int b){ return (a>b)?a:b; }
int count(int a,int b){
	if(a<=0||b<=0) return 0;
	if(memo[a][b] != -1) return memo[a][b];
	memo[a][b] = 1+max(count(a+1,b-2),count(a-2,b+1));
	return memo[a][b];
}
int main(){
	int a,b;
	init();
	scanf("%d%d",&a,&b);
	int rez = count(a,b);
	printf("%d\n",rez);
	return 0;
}

#include <stdio.h>
int abs(int a) {
  return a>0?a:-a;
}
int min(int a, int b) {
  return a<b?a:b;
}
int main(void) {
  int a,b;
  scanf("%d%d",&a,&b);
  if (a+b<4) printf("0\n");
  else if ((a-b)%3==0)
    printf("%d\n",(min(a,b)+abs(a-b)/3-2)*2+1+abs(a-b)/3);
  else printf("%d\n",abs(a-b)/3+abs(a-b)%3+(min(a,b)+abs(a-b)/3-1)*2);
  return 0;
}

#include <stdio.h>

int main(){

	int p1, p2, total;

	scanf("%d %d",&p1,&p2);
	total = 1;
	while(p1-2 >= 1 || p2-2 >= 1){
		if(p1 <= p2){
			p1++;
			p2 -= 2;
			total++;
		}
		else if(p1 > p2){
			p2++;
			p1 -= 2;
			total++;
		}
	}
	printf("%d", total);

	return 0;
}

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

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

#include <stdio.h>

int main(void) {
	int r[2],conn=0,min=-1;
	scanf("%d%d",&r[0],&r[1]);
	while(1){
		if(r[0]>r[1]) conn=1;
		else conn=0;
		r[conn]++;
		r[!conn]-=2;
		if(r[0] < 0 || r[1] < 0) break;
		min++;
	}
	printf("%d",min);

	return 0;
}

#include<stdio.h>
int main()
{
    int a , b , min , max ;

    scanf("%d%d",&a,&b);
    if(a-2 <=0 && b-2 <=0){
        printf("0");
        return 0 ;
    }
    min = a > b ? b : a ;

    max = a+b-min ;
    b = 0 ;
    while(min > 0 && max > 0)
    {
        max -= 2;
        min++ ;
        b++;
        if(min > max){
            a = min ;
            min = max ;
            max = a ;
        }

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

}

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