#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    int a1,a2;
    int time=0;
    scanf("%d %d",&a1,&a2);
    if (a1>a2) {
        int x=a2;
        a2=a1;
        a1=x;
    }
    for (; ; time++) {
        if (a1<3) {
            int x=a2;
            a2=a1;
            a1=x;
            if (a1==2) {
                time++;
                break;

            }
            if (a1==1) {
                break;
            }
        }
        a1-=2;
        a2++;
    }
    printf("%d\n",time);
    return 0;
}

/// in the name of ALLAH

#include <bits\stdc++.h>

#define bits(a) __builtin_popcount(a)
#define ll long long
int dx[] = {1 , -1 , 0 , 0 };
int dy[] = {0 ,  0 , 1 , -1};
const int mod = 1e9 + 7;
const int oo = 1<<30;
const ll loo = (ll)1<<60;
const double pi = 3.14159265359;
const int N = 2e5 + 1;

using namespace std;

int main(){
    int c = 0 ,a , b;
    cin >> a >> b;
    while(b > 0 && a > 0){
        if(a == 1 && b == 1)
        break;
        if(a < b)
           swap(a , b);
        int diff = (a-b+1)/2;
        diff = min(diff , (a-1)/2);
        diff = max(diff , 1);
        c += diff;
        b += diff;
        a -=diff*2;
    }
    cout << c;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a1,a2,t=0;
    cin>>a1>>a2;
    while(a1>0&&a2>0)
    {
        if(a1==1&&a2==1)
            break;
        if(a1<=a2)
        {
            a1+=1;
            a2-=2;
            t++;
        }
        else
        {
            a2+=1;
            a1-=2;
            t++;
        }
    }
    cout<<t;
    return 0;
}

#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int ans=0;
    while(n>0&&m>0)
    {
        if(n==1&&m==1)break;
        if(n>m)
        {
            int a=n;
            n=m;
            m=a;
        }
        n+=1;
        m-=2;
        ans++;
    }
    printf("%d\n",ans);
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <string.h>
#include <queue>
#include <stack>
#include <map>
#include <math.h>
#include <list>
using namespace std;
#define abs(a) ((a > 0)? (a):(-(a)))
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))

int main(){
	int a,b;
	cin >> a >> b;
	int answ = 0;
	while(min(a,b) > 0){
		if( a == 1 && b == 1)
			break;
		if( a > b){
			b++;
			a-=2;
		}
		else{
			a++;
			b-=2;
		}

		answ++;
	}
	cout<<answ;
	return 0;
}

/*hnda*/
#include<iostream>

using namespace std;

 int main()
 {
     int a,b;
     int time=0;
     int flag=0;
     cin>>a>>b;
     while(a>0&&b>0)
     {
         if(a==b&&a==1)
         {
             cout<<"0"<<endl;
             flag=1;
             break;
         }
         if(a>b)
        {
            swap(a,b);
        }
         a=a+1;
         b=b-2;
         time++;

     }
     if(flag==0)
     cout<<time<<endl;
 }

#include <bits/stdc++.h>
#define pvar(x) clog<<"["<<#x<<":"<<x<<"]\n"
using namespace std;
using ll = long long int;
int dp[201][201];
int calc(int a, int b){
	if(a<=0 || b<=0)return 0;
	if(a==1 && b==1)return 0;
	else if(a==1 && dp[a][b] ==-1)dp[a][b] = 1+calc(a+1,b-2);
	else if(b==1 && dp[a][b] ==-1)dp[a][b] = 1+calc(a-2,b+1);
	else if(dp[a][b]==-1)dp[a][b] = 1 + max(calc(a+1,b-2),calc(a-2,b+1));
	return dp[a][b];
}
int main(){
	int a,b;
	cin>>a>>b;
	memset(dp,-1,sizeof(dp));
	cout<<calc(a,b);
}

/*ek4x*/
#include <stdio.h>
#include <stdlib.h>
int a1,a2,count = 0;
void use(void){
    if(a1 > 0 && a2 > 0){
        if(a1 > a2){
            a1-=2;
            a2++;
        }
        else{
            a2 -= 2;
            a1++;
        }
    }
    else{
        if(a1 <= 0)
            a2-=2;
        else
            a1-=2;
    }
    count++;
}

int main(){
    scanf("%d %d",&a1,&a2);
    if(a1<2&&a2<2)
        printf("0");
    else{
        do use();
        while(a1 != 0 && a2 != 0);
        printf("%d",count);
    }
    return 0;
}

#include<iostream>
using namespace std;
void main()
{
	int m, n, s = 0;
	cin >> m >> n;
	if (m == 1 & n == 1)
		s--;
		while (m>0&n>0)
		{
			if (m < n)
			{
				m++;
				n -= 2;
			}
			else
			{
				n++;
				m -= 2;
			}
			s++;
		}

	cout << s;
}

#include<bits/stdc++.h>
using namespace std;
int a,b,ans;
int main()
{
    cin>>a>>b;
    if(a==1 && b==1){
        cout<<0<<endl;
        return 0;
    }
    while(a>0 && b>0){
        if(b<a) b++,a-=2;
        else a++,b-=2;
        ans++;
    }
    cout<<ans<<endl;
}

#include <iostream>
using namespace std;

int main()
{
   int a,b;
   cin>>a>>b;
   int ans=0;
   if(a==1&&b==1)
   {
       ans=0;
   }
   else{
   while(a>0 && b>0)
   {

       if(a>b)
       {
           a-=2;
           b+=1;
           ans++;

       }
       else
       {
           a+=1;
           b-=2;
           ans++;

       }
   }
   }
   cout<<ans;
    return 0;
}

#include <iostream>

using namespace std;

int k;
int main()
{
    int sdp(int x,int y),a,b,temp;
    while(cin>>a>>b)
    {
        if(a>b)
        {
            temp=a;
            a=b;
            b=temp;
        }
        k=0;
        cout<<sdp(a,b)<<endl;
    }
}
int sdp(int x,int y)
{
    x++;
    y-=2;
    k++;
    if(y==0)
    return k;
    else if(y==1||y==2)
    return sdp(y,x);
    else if(y==-1)
    return k-1;
    else
    return sdp(x,y);
}

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int time = 0;
    int js1 =0;
    int js2 =0;
    cin >> js1 >> js2;
    if(js1 <2 && js2<2)
    time= -1;
    while(js1>0 && js2>0){
    time++;
    if (js1 > js2)
    {
       js2++;
       js1 = js1 - 2;
       continue;
       }
    if (js2 > js1){
       js1++;
       js2 = js2 - 2;
       continue;
       }
    if(js1 == js2)
    {
     js1++;
     js2 = js2-2;
     continue;
     }
    }
    cout << time;
    return 0;
}

// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int ans,a1,a2;
int main(){
    scanf("%d%d",&a1,&a2);
    if(a1==1&&a2==1) cout<<0;
    else{
        while(a1>0&&a2>0){
            ans++;
            if(a1<a2) a2-=2,a1++;
            else a2++,a1-=2;
        }
        cout<<ans;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long i,j,m,n,p,q,r,c,mm;
set<long long>s;
int main()
{
cin>>m>>n;
if(m==1&&n==1)
{
    cout<<0;
    return 0;
}
while(n>0&&m>0)
{
    mm=min(m,n);
    //cout<<mm;
    if(m==mm)
    {
        while(n)
        {
            c++;
            m+=1;
            n-=2;
            if(n==2||n==1)
                break;
        }
    }
    else
    {
        while(m)
        {
            c++;
            n+=1;
            m-=2;
            if(m==1||m==2)
                break;
        }

    }
}
cout<<c;
}

#include<bits/stdc++.h>
#define CLR(a)              memset(a, 0, sizeof(a))
#define SET(a, x)           memset(a, x, sizeof(a))
#define SORT(v)             sort(v.begin(), v.end())
#define REV(v)              reverse(v.begin(), v.end())
#define FOR(i, n)           for (int i=0; i<n; i++)
#define FOR1(i, n)          for (int i=1; i<=n; i++)
#define ROF(i, n)           for (int i=n-1; i>=0; i--)
#define ROF1(i, n)          for (int i=n; i>=1; i--)
#define LOOP(i, x, n)       for (int i=x; i<=n; i++)
#define READ(x)             freopen(x, "r", stdin);
#define WRITE(x)            freopen(x, "w", stdout);
#define fastIO()            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI                  acos(-1.0)
#define pb                  push_back
#define mp                  make_pair
#define fi                  first
#define se                  second

using namespace std;

typedef long long              ll;
typedef unsigned long long     ull;
typedef vector<int>            vi;
typedef pair<int, int>         pii;
typedef pair<string, int>      psi;
typedef pair<char, int>        pci;

const double eps = 1e-9;

int fx[] = {-1, 1, 0, 0, -1, -1, 1, 1};
int fy[] = {0, 0, -1, 1, -1, 1, -1, 1};

int TLx[] = {0, -1, -1, 0};    int TLy[] = {-1, -1, 0, 0};
int TRx[] = {-1, -1, 0, 0};    int TRy[] = {0, 1, 1, 0};
int BLx[] = {0, 1, 1, 0};      int BLy[] = {-1, -1, 0, 0};
int BRx[] = {0, 1, 1, 0};      int BRy[] = {1, 1, 0, 0};

int main()
{
    int a, b, cnt = 0; cin >> a >> b;
    while(a>0 && b>0){
        if (a<b){
            a++;
            b -= 2;
        }
        else{
            b++;
            a -= 2;
        }
        if (a>=0 && b>=0) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

#include <iostream>
#include <math.h>

using namespace std;

int main()
{
	int
		fir, sec,	//Заряд 1, 2
		min = 0;	//Время игры

	cin >> fir >> sec;
	while (fir > 1 || sec > 1)
	{
		if (fir > 2)
		{
			sec++;
			fir -= 2;
			min++;
		}
		else if (sec > 2)
		{
			fir++;
			sec -= 2;
			min++;
		}
		else
		{
			min++;
			break;
		}
	}
	cout << min;
	return 0;
}

#include<iostream>
using namespace std;
int a1,a2,s;
int main()
{
    cin>>a1>>a2;
    if(a1==a2&&a1==1){cout<<"0\n";return 0;}
    while(a1&&a2)
	{
        s++;
        if(a1<a2)a1++,a2-=2;
        else a1-=2,a2++;
    }
    cout<<s<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a1,a2,sum=0;
	cin>>a1>>a2;
	while(a1>0&&a2>0)
	{
		if(a1>a2) swap(a1,a2);
		a1+=1;
		a2-=2;
		if(a2<0) break;
		sum++;
	}
	cout<<sum;
	return 0;
}

/*fqdm*/
#include "iostream"
#include "cstdio"
#include "cstdlib"
#include "cstring"
#include "string"
#include "algorithm"
#include "queue"
#include "cmath"
using namespace std;
int a,b;
int main(){
    cin>>a>>b;
    if(a==1&&b==1){
        cout<<0<<endl;
        return 0;
    }
    int cnt=0;
    while(a>0&&b>0){
        cnt++;
        if(a>b){
            int temp=a;
            a=b;
            b=temp;
        }
        a+=1;
        b-=2;
    }
    cout<<cnt<<endl;
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
/*
int main()
{
	int a,b;
	cin >>a >>b;
	int cou=0;
	while (a>0 && b>0) {
		cou++;
		if (a>b){
			int temp=a;
			a=b;
			b=temp;
		}
		a+=1;
		b-=2;
	}
	cout <<cou <<endl;
	return 0;
}
Wrong Answer
*/
/*
int main()
{
	int dp[101][101]={};
	int i,j;
	for (i=1;i<=100;i++) {
		dp[1][i]=1;
		dp[i][1]=1;
	}
	for (i=2;i<=100;i++) {
		for (j=2;j<=100;j++) {
			int m=(dp[i-2][j+1]>dp[i+1][j-2])?dp[i-2][j+1]:dp[i+1][j-2];
			dp[i][j]=m+1;
		}
	}
	int a,b;
	cin >>a >>b;
	cout <<dp[a][b] <<endl;
	return 0;
}*/

long dp[1000][1000];

long findAns(int x,int y)
{
	if (x<=0 || y<=0 || x==1&&y==1) return 0;
	if (dp[x][y]!=0) return dp[x][y];
	long k1=findAns(x-2,y+1)+1;
	long k2=findAns(x+1,y-2)+1;
	long ans=(k1>k2)?k1:k2;
	dp[x][y]=ans;
	dp[y][x]=ans;
	return ans;
}

int main()
{
	int a,b;
	cin >>a >>b;
	cout <<findAns(a,b) <<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define db(x) cerr << #x << " == " << x << endl;
#define _ << " " <<

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

const long double EPS = 1e-9;
const int N=1e5+5;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;

int a,b;

int main()
{
	cin >> a >> b;
	if(a==1 and b==1) return cout << 0 << endl, 0;
	cout <<  a+b-2 - ((a-b)%3==0) << endl;
}

// 1518984509825

#include <iostream>
using namespace std;
int mx=0;
int a[151][151]={0};
void f(int x,int y,int t){
	if(a[x][y]){
		return;
	}
	a[x][y]=1;
	if(!(x&&y)){
		mx=max(t,mx);
		return;
	}
	if(x==1){
		f(x+1,y-2,t+1);
		return;
	}
	if(y==1){
		f(x-2,y+1,t+1);
		return;
	}
	f(x+1,y-2,t+1);
	f(x-2,y+1,t+1);
}
int main(){
	int x,y;
	cin>>x>>y;
	if(x==1&&y==1){
		cout<<0;
		return 0;
	}
	f(x,y,0);
	cout<<mx;
}

/*ab0l*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int a,b;
    while(cin >> a >> b)
    {
        int sum = 0;
        if(a==1&&b==1)
        {
            cout << 0 << endl;
            continue;
        }
        while(a>0&&b>0)
        {
            if(a==2&&b==1||a==1&&b==2||a==2&&b==2)
            {
                sum++;
                break;
            }
            while(a>2)
            {
                a = a-2;
                b += 1;
                sum++;
            }
            while(b>2)
            {
                b = b-2;
                a +=1;
                sum++;
            }
        }
        cout << sum <<endl;

    }
    return 0;
}

#include <cstdio>
#include <algorithm>

using namespace std;

bool visit[401][401];
int dp[401][401];

void init() {
    for (int i = 0; i <= 400; i++) {
        for (int j = 0; j <= 400; j++) {
            visit[i][j] = false;
            dp[i][j] = 0;
        }
    }
}

int solve(int a, int b) {
    if (a <= 0 || b <= 0) return 0;
    if (visit[a][b]) return dp[a][b];
    visit[a][b] = true;
    int di[2] = {-2, 1};
    int dj[2] = {1, -2};
    for (int i = 0; i < 2; i++) {
        if (i == 0 && a == 1) continue;
        if (i == 1 && b == 1) continue;
        dp[a][b] = max(dp[a][b], solve(a + di[i], b + dj[i]) + 1);
    }
    return dp[a][b];
}

int main(void) {
    int a, b;
    while (scanf("%d %d", &a, &b) == 2) {
        init();
        printf("%d\n", solve(a, b));
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int a1,a2;
int dp[120][120];
int vis[120][120];
int solve(int x,int y)
{
    if(x>y)swap(x,y);
    if(x<=0)return 0;
    if(vis[x][y])return dp[x][y];
    vis[x][y]=1;
    dp[x][y]=max(solve(x-2,y+1),solve(x+1,y-2))+1;
    return dp[x][y];
}
int main()
{
    cin>>a1>>a2;
    if(a1==1&&a2==1)return puts("0"),0;
    cout<<solve(a1,a2)<<endl;
}

/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define mod 1000000000000000001
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=r*x;
        x=x*x;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=c[j]+c[j-1];
    }
    return c[k];
}

bool prime[500001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100001);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100001;j=j+i)
                prime[j]=false;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b,i,j,f=0;
    cin>>a>>b;
    if(a>b)
        swap(a,b);
    if((a==1 && b==1))
    {
        cout<<0;
        return 0;
    }

    f=0;
    while(min(a,b)>0)
    {
        if(a>b)
        {
            a=a-2;
            b=b+1;
        }
        else
        {
            a++;
            b=b-2;
        }

        f++;
    }
    cout<<f;

    return 0;

}

#include <iostream>

using namespace std;

int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        int ans=0;
        while(a>0&&b>0)
        {
            if(a==1&&b==1) break;
            if(a>b)
            {
                b++;
                a-=2;
            }
            else
            {
                a++;
                b-=2;
            }
            ans++;
        }
        cout << ans << endl;
    }

    return 0;
}

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int j1,j2,miin,maax,sum=0;
    cin>>j1>>j2;
    miin=min(j1,j2);
    maax=max(j1,j2);

    if (miin<2&&maax<2){
            cout<<sum;
            return 0;
    }
     if (miin<=2&&maax<=2){
            cout<<++sum;
            return 0;
    }

    while(true){
            miin++;
    maax-=2;
    sum++;

        if (miin<=2&&maax<=2){
            sum++;
            break;
        }

        if (maax<=2)swap(miin,maax);

    }
    cout<<sum;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int a1, a2, ans;
int main() {
    cin >> a1 >> a2;
    while (a1 > 0 && a2 > 0) {
        if (a1 == 1 && a2 == 1) {
            break;
        }
        if (a1 > a2 || a2 == 1) {
            ----a1;
            a2++;
        } else {
            a1++;
            ----a2;
        }
        ++ans;
    }
    cout << ans << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a,b,s;
int main(){
	cin>>a>>b;
	while(a>0&&b>0){
		if(a>b)a-=2,b+=1;
		else b-=2,a+=1;
		//if(b>0&&a>1||b>1&&a>0)
		s++;
		if(a<0||b<0)s--;
	}
	cout<<s;
	return 0;
}

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

#include <iostream>
#include <cstdio>
using namespace std;

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

/*nyg0*/
#include <cstdio>
#include <algorithm>
using namespace std;

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

/*zhte*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,ans;
int main(){
        scanf("%d%d",&n,&m);ans=0;
        while (1){
        if (n<=0||m<=0)break;
        if (n>m)swap(n,m);
        if (m-2<0)break;
        ans++;
        n++;m-=2;
        }
        printf("%d\n",ans);
        return 0;
}

/*u8rc*/
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
	int n,m;
	int ans=0;
	cin>>n>>m;
	while((n>0&&m>=2)||(m>0&&n>=2))
	{
		ans++;
		if(n>m) m+=1,n-=2;
		else n+=1,m-=2;
	//	cout<<n<<" "<<m<<endl;
	}
	cout<<endl;
	cout<<ans;
}

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int s = 0, a, b;
    cin >> a >> b;
    while(a > 0 && b > 0){
        if(a == 1 && b == 1)
        break;
        if(a > b)
            swap(a, b);
        a++;
        b -= 2;
        s++;
    }
    cout << s << endl;
    return 0;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    ll a1, a2;
    cin >> a1 >> a2;
    ll res = 0;
    while (true) {
        if ((a1 <= 0 || a2 <= 0) || (a1 == 1 && a2 == 1)) break;
        if (a1 > a2) swap(a1, a2);
        a1++; a2 -= 2; res++;
    }
    cout << res << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main() {
	int i,j,k,l=0,n,m;
	cin>>n>>m;
	while(n>2 || m>2) {
		if(n<m) {
			n+=1;
			m-=2;
		}
		else {
			m+=1;
			n-=2;
		}
		l++;
	}
	if(n<=1&&m<=1);
	else if(n==1&&m==2)
		l++;
	else if(n==2&&m==1)
		l++;
	else if(n==2&&m==2)
		l++;
	cout<<l<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

const int maxn = 1e5 * 4;

inline int g() {
    int x;
    cin >> x;
    return x;
}

inline long long gl() {
    long long x;
    cin >> x;
    return x;
}

inline string gs() {
    string s;
    cin >> s;
    return s;
}

template<typename T>
inline vector<T> gv(int len) {
    vector<T> a(len);
    for (auto &it : a)
        cin >> it;
    return a;
}

inline vector<int> gv(int len) {
    vector<int> a(len);
    for (auto &it : a)
        cin >> it;
    return a;
}

inline vector<pair<int, int>> gv_andPairCnt(int len) {
    vector<pair<int, int>> a(len);
    int i = 1;
    for (auto &it : a) {
        it.second = i;
        i++;
        cin >> it.first;
    }
    return a;
}

double power_log(double power, double val) {
    return log(val) / log(power);
}

template <typename T>
T sqr(T x) { return x * x; }

#define rep(I, N) for (int I = 0; I < (N); ++I)
#define rep_range(VALUE, LEFT, RIGHT) for (int VALUE = (LEFT); VALUE < (RIGHT); ++VALUE)

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for (auto it : v)
        os << it << "";
    os << "\n";
    return os;
}

template<typename T, typename H>
inline vector<pair<T, H>> gv_andBiPair(int len) {
    vector<pair<T, H>> a(len);
    for (auto &it : a) {
        cin >> it.first >> it.second;
    }
    return a;
}

template<typename T>
inline set<T> vector_to_set(const vector<T> &vec) {
    set<T> s;
    for (auto &it : vec)
        s.insert(it);
    return s;
}

int main() {
    int a1 = g(), a2 = g(), ans = 0;
    while(a1 > 0 && a2 > 0) {
        if(a1 == 1 && a2 == 1) break;
        if(a1 < a2) swap(a1, a2);
        a1 -= 2, a2 += 1, ans++;
    }
    cout << ans;
}

    #include <bits/stdc++.h>
    #define forall(i, a, b) for(int i = 0; i < b; ++i)
    #define forallc(i, a, b) for(int i = 0; i <= b; ++i)
    typedef long long ll;

    using namespace std;

    int main(){
        int a, b;
        cin >> a >> b;
        int result = 0;
        while(a != 0 && b != 0){
            if((b == 1 || b == 2) && (a == 1 || a == 2)){
                if(!(a == 1 && b == 1))
                ++result;
                break;
            }
            if(a == 1 || a == 2){
                if(b % 2 == 0){
                    result += ((b - 2) / 2);
                    a += ((b - 2) / 2);
                    b = 2;
                }else{
                    result += (b / 2);
                    a += (b / 2);
                    b = 1;
                }
            }else{
                if(a % 2 == 0){
                    result += ((a - 2) / 2);
                    b += ((a - 2) / 2);
                    a = 2;
                }else{
                    result += (a / 2);
                    b += (a / 2);
                    a = 1;
                }
            }
        }
        cout << result;
        return 0;
    }

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <random>
using namespace std;

int d[1010][1010];

int rec(int a, int b) {
    if (d[a][b] != -1)
        return d[a][b];

    d[a][b] = 0;
    if (a >= 2 && b > 0)
        d[a][b] = max(d[a][b], 1 + rec(a - 2, b + 1));
    if (a > 0 && b >= 2)
        d[a][b] = max(d[a][b], 1 + rec(a + 1, b - 2));
    return d[a][b];
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    for (int i = 0; i < 1010; i++) {
        fill(d[i], d[i] + 1010, -1);
    }

    int a, b;
    cin >> a >> b;

    cout << rec(a, b);
}

/*byyp*/
#include<stdio.h>
int max(int a,int b)
{
    if(a>b)return a;
    else return b;
}
int min(int a,int b)
{
    if(a>b)return b;
    else return a;
}
int main()
{
    int m,n,t,x,y;
    while(~scanf("%d%d",&m,&n))
    {
        t=0;
        while(m>0&&n>0)
        {
            if(m==1&&n==1)break;
            t++;
            x=min(m,n)+1;
            y=max(m,n)-2;
            m=x;
            n=y;
        }
        printf("%d\n",t);
    }
}

#include<bits/stdc++.h>
using namespace std;

int main(){
    int x,y;
    scanf("%d%d",&x,&y);
    int cnt=0;
    while(x>0&&y>0){
        if(x==1&&y==1){
            break;
        }
        if(x>y){
            x-=2;
            y+=1;
        }
        else{
            y-=2;
            x+=1;
        }
        cnt++;
    }
    printf("%d",cnt);
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<utility>
#include<set>
#include<queue>
using namespace std;

typedef pair<int, int> P;
typedef unsigned __int64 ULL;
const int INF = 0x3fff3fff;
const int PI = acos(-1);

int n, m;

int main(){
    //freopen("Atds.txt", "r", stdin);
    while(~scanf("%d%d", &n, &m)){
        int res = 0;
        while(n > 0 && m > 0){
            res++;
            if(n >= m){
                n -= 2;
                m++;
            }
            else {
                m -= 2;
                n++;
            }
        }
        if(n < 0 || m < 0)res--;
        printf("%d\n", res);
    }
    return 0;
}

//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#include<string>
#include<algorithm>
#include<iomanip>
#include<vector>
void fast()
{
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
int main()
{
		fast();
		//freopen("circle.in", "r", stdin);
		//freopen("circle.out", "w", stdout);
		//cout<<fixed<<setprecision(6);

	int n,m;
	cin>>n>>m;

	if(m<n)
		swap(n,m);
	int t=0;
	while(n>1 || m>1)
	{
		++t;
		n++;
		m-=2;
		if(m<n)
		swap(n,m);
		//cout<<n<<" "<<m<<endl;
		if( n<=0 || m<=0)
		 break;

	}
	/*if(n<=0 || m<=0)
	cout<<t-1;
	else */cout<<t;
//	system("pause");
	return 0;
}

#include <iostream>
using namespace std;
long long a,b,r=0;
int main() {
	cin >> a >> b;
	if((a==1)&&(b==1)){
		cout << 0;
		return 0;
	}
	while((a>0)&&(b>0)){
		if(a>=b){
			b+=1;
			a-=2;
		}else{
			a+=1;
			b-=2;
		}
		r++;
	}
	cout << r;
	return 0;
}

/*ejol*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    int a,b;
    int coun;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        coun=0;
        if(a<2&&b<2){
            printf("0\n");
            continue;
        }
        else
        {
            while(a>0&&b>0)
            {
                if(a>2){a-=2;b++;}
                else {b-=2;a++;}
                coun++;
            }
        }
        printf("%d\n",coun);
    }
    return 0;
}

#include <iostream>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	int minutes = 0;
	while(a > 0  && b > 0)
	{
		if ( b <= 2)
		{
			int temp = a;
			a = b;
			b = temp;
		}
		if(b==1 && a == 1)
			break;
		b-= 2;
		a++;
		minutes++;
	}

	cout << minutes << endl;
	//cout << a+b << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int charge(int i,int j,int k){
    if(i==1&&j==1||i<=0||j<=0)
        return k;
    else
        if(j==1||j==2)
            charge(i-2,j+1,k+1);
        else
            charge(i+1,j-2,k+1);
}
int main(){
    int a1,a2;
    cin>>a1>>a2;
    cout<<charge(a1,a2,0);
    return 0;
}

#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <cstring>
#include <cstdlib>
#include <map>
#include <ctime>
#include <queue>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define forn(i, l, r) for(int i = l; i < r; i ++)
#define pii pair <int, int>
#define vi vector <int>
#define N 1005
#define y1 stupid_cmath
#define sz(a) (int)a.size()
#define ll long long
#define all(a) a.begin(), a.end()

const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-9;
const int maxn = (int)1e5 + 11;

int main () {
    #ifdef LOCAL
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
    #endif

    int a, b, cnt = 0;

    scanf("%d%d", &a, &b );
    if (a<b) swap(a,b);

    while (true) {
    	if (a==0 || b==0) break;
    	if (a<b) swap(a,b);
    	if (a-2>=0) a-=2, b++, cnt++; else
    	if (b-2>=0) b-=2, a++, cnt++; else
    	break;
    }
    cout << cnt;

	#ifdef LOCAL
    cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl;
    #endif

    return 0;
}

/*** What one man can do, another can do.
** Stay hungry ,stay foolish..
** Don't wait for the perfect moment.. take the moment and make it perfect :)
** Always try to face more complicated challenges,you can not gain sucess always,but will learn :)
*/
#include <bits/stdc++.h>
using namespace std;
#define max 50000
#define ll long long
#define vsort(v)   sort(v.begin(),v.end())
int main(void){
   int a,b,small,big,count = 0;
    cin>>a>>b;
    if(a>b) small = b, big =a;
    else if(b>a) small = a, big = b;
    else small = b, big = a;
    if(a-2<=0 && b-2<=0 && a==1 && b==1) cout<<0<<endl;
    else {
    while(1){
        if(small-2<=0 && big-2<=0){
           count++;
           break;
         }
        else{
           small++, big-=2;
           //cout<<small<<" "<<big;
           count++;
           a = small, b = big;
           if(a>b) small = b, big =a;
           else if(b>a) small = a, big = b;
           else small = b, big = a;
           //cout<<"now big = "<<big<<" small = "<<small<<endl;
        }
    }
  cout<<count<<endl;
 }

}

/*1c4d*/
#include <iostream>

using namespace std;

int main()
{
    int a1,a2;
    cin>>a1;
    cin>>a2;
    int sum=0;
    int f1=1;
    int f2=-2;
    if(a1==1&&a2==1)
    {
    cout<<sum;
    }
    else{
        while(a1>0&&a2>0){
            if(a1<=a2){
                a1+=f1;
                a2+=f2;
            }
            else{
                a1+=f2;
                a2+=f1;
            }
            sum++;
        }
        cout<<sum;
    }
    return 0;
}

#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <cstdio>
#include <fstream>
#include<iomanip>
#include<bitset>
#define fastIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define ff first
#define ss second
using namespace std;
const int MAX = 1e6 + 5;
const int MAX_DIST = 1e9 + 7;
/*
vector<int>v[106];
map<int, int> ans;
bool visit[1000];
void dfs(int n) {
//if (!visit[n])visit[n] = true;
for (int i = 0; i < v[n].size(); i++) {
ans[v[n][i]]--;
visit[v[n][i]] = true;
//dfs(v[n][i]);
}
}

char s[10001][10001];
int dist(int row) {
int l = 0;
while (s[row][l] != 'G') l++;
int r = 0;
while (s[row][r] != 'S') r++;
if (r < l) return -1;
return r - l;
}*/
int n, m;
int main() {
	fastIO;
	cin >> n >> m;
	int c = 0;
	if (n == 1 && m == 1) {
		return cout << 0 << endl,0;
	}
	while (n>0&&m>0)
	{
		if (n > m) {
			m += 1;
			n -= 2;
		}
		else
		{
			n += 1;
			m -= 2;
		}
		c++;
	}
	cout << c << endl;
	return 0;
}

#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
int n,m;
inline void joystick(int x,int y,int z){if((x<=0)||(y<=0)||(!((x+y)-2))){printf("%d",z);return;}(((!(y-1))||(!(y-2)))?(joystick((x-2),(y+1),(z+1))):(joystick((x+1),(y-2),(z+1))));}
int main()
{
	scanf("%d%d",&n,&m);
	joystick(n,m,0);
	return putchar(10),0;
}

#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main(){
    io
    int a[2],c=0;
    cin>>a[0]>>a[1];
    while(a[0]>1 || a[1]>1){
        //cout<<a[0]<<" "<<a[1]<<endl;
        if(a[0]==0 || a[1]==0){
            break;
        }
        c++;
        if(a[0]<a[1]){
            a[0]++;
            a[1]-=2;
        }
        else{
            a[1]++;
            a[0]-=2;
        }
    }
    cout<<c<<endl;
    return 0;
}

#include<bits/stdc++.h>
#define ull unsigned long long
# define lli long long int
#define ll long long
#define db double
#define ldb long double
#define vi vector<int>
#define vull vector<ull>
#define vll vector<ll>
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define si set<int>
#define sll set<ll>
#define ins insert
#define vpp vector<pair<int,int>>
#define mp make_pair
#define ft first
#define sc second
#define mod 1000000007
using namespace std;
/*lli power(lli a,lli n)
{lli ans=1;
   while(n>0)
   {
      if(n%2)
       {
         ans=ans*a;
         n--;
       }
      else
        {
         a=a*a;
         n=n/2;
        }
  }
return ans;
 }*/
/*ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}*/
/*int is_prime[1000001];
void sieve(){
    int maxN=1000000;
    for(int i=1;i<=maxN;i++)
    is_prime[i]=1;
    is_prime[0]=is_prime[1]=0;
    for(int i=2;i*i<=maxN;i++)
    {
        if(is_prime[i])
        {
            for(int j=i*i;j<=maxN;j+=i)
            is_prime[j]=0;
        }
    }
}*/
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
        int a,b;
        cin>>a>>b;
        int count=0;
        if(a==1 && b==1)
        {
        	cout<<0;
        	return 0;
        }
        while(a>0 && b>0)
        {
        	if(a>=b)
        	{   while(a>2)
        	     {
        	         count++;
        	         a=a-2;
        	         b=b+1;
        	     }
        	}
        	else
        	{
        		while(b>2)
        		{
        			count++;
        			b=b-2;
        			a=a+1;
        		}
        	}

        	if(a==2 && b==2)
        	{
        		count++;
        		break;
        	}
        	else if(a==2 && b==1 || b==2 && a==1)
        	{
        		count++;break;
        	}

        }
        cout<<count;
return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define optimize              ios_base::sync_with_stdio(false)
#define FOR(i, a, n)          for(int i = a; i < n; i++)
#define from_0_to(x)          for(int i = 0; i < x; i++)
#define LL                    long long
#define ULL                   unsigned long long
#define YES()                 printf("YES\n")
#define NO()                  printf("NO\n")
#define NL()                  printf("\n")
#define PI                    acos(-1)
#define veci                  vector <int>
#define vecll                 vector < long long >
#define p_b                   push_back
#define pii                   pair < int, int >
#define pci                   pair <char, int >
#define psi                   pair <string, int>
#define m_p                   make_pair
#define max3(a, b, c)         max(a, max(b, c))
#define min3(a, b, c)         min(a, min(b, c))
#define valid(tx,ty)          (tx>=0&&tx<C&&ty>=0&&ty<R)
#define MX                    10000001
#define mod                   1e9 + 7
#define sf1(a)                scanf("%d",&a)
#define sf2(a,b)              scanf("%d %d",&a,&b)
#define sf3(a,b,c)            scanf("%d %d %d",&a,&b,&c)
#define pf1(a)                printf("%d\n",a);
#define pf2(a,b)              printf("%d %d\n",a,b)
#define pf3(a,b,c)            printf("%d %d %d\n",a,b,c)
#define sf1ll(a)              scanf("%lld",&a)
#define sf2ll(a,b)            scanf("%I64d %I64d",&a,&b)
#define sf3ll(a,b,c)          scanf("%I64d %I64d %I64d",&a,&b,&c)
#define pf1ll(a)              printf("%lld\n",a);
#define pf2ll(a,b)            printf("%I64d %I64d\n",a,b)
#define pf3ll(a,b,c)          printf("%I64d %I64d %I64d\n",a,b,c)
#define STRTOLOWER(x)         std::transform (x.begin(), x.end(), x.begin(), ::tolower)
#define STRTOUPPER(x)         std::transform (x.begin(), x.end(), x.begin(), ::toupper)
#define STRTOUCFIRST(x)       std::transform (x.begin(), x.begin()+1, x.begin(),  ::toupper); std::transform (x.begin()+1, x.end(),   x.begin()+1,::tolower)
//int a[MX], b[MX], sol[MX];
//int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}
//ll dx[]={1,0,-1,0,1,-1,-1,1};
//ll dy[]={0,1,0,-1,1,1,-1,-1};
//int dx = {1, 1, 2, 2, -1, -1, -2, -2}
//int dy = {2, -2, 1, -1, 2, -2, 1, -1}
int t, n, N, p, q, r, c, R, C,  m, mn = 1e9 + 9, mx = 0, tt, height, width;
long long ans, s;
bool check = false;

int main()
{
    cin.tie(0);
    cout.tie(0);
    optimize;
    //freopen("input.txt", "r", stdin);
    cin >> p >> q;
    while( p > 0 && q > 0 && (p >= 2 || q >= 2) ){
        if(p < q) swap(p, q);
        p -= 2;
        q += 1;
        //if(p < 1 || q < 1) break;
        c++;
    }
    cout << c << endl;
    return 0;
}

#include<iostream>
#include<climits>
#include<algorithm>
#include<cstdio>
#include<string.h>
#include<utility>
using namespace std;
typedef signed long long ll;

int main() {

   int a,b;
    cin >> a >> b;
    int count=0;

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

            if(a==1 && b==1){
                break;
            }

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

            count++;
        }

        printf("%d", count);

}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cmath>

using namespace std;

void binarySearch(vector<int>* arr, int* num, int* low, int* mid, int* high) {

	while (true) {

		if (arr->at(*mid) <= *num && arr->at(*mid + 1) > * num) {
			break;
		}
		else if (*num > arr->at(*mid)) {
			*low = *mid;
			*mid = (*low + *high) / 2;
		}
		else if (*num < arr->at(*mid)) {
			*high = *mid;
			*mid = (*high + *low) / 2;
		}

	}

}

void gcd(int* a, int* b, int* _gcd) {
	if (*a == *b) {
		*_gcd = *a;
	}
	else if ((*a % 2 == 0 && *b % 2 != 0) || (*a % 2 != 0 && *b % 2 == 0)) {
		*_gcd = 1;
	}
	else if (*a == 0 || *b == 0) {
		*_gcd = 1;
	}
	else if (*a > * b) {
		for (int i = 2; i < *a / 2; i++) {
			if (*a % i == 0 && *b % i == 0) {
				*_gcd *= i;
				*a /= i;
				*b /= i;
				i--;
			}
			if (*a == 1 || *b == 1) {
				break;
			}
		}
	}
	else if (*b > * a) {
		for (int i = 2; i < *b / 2; i++) {
			if (*a % i == 0 && *b % i == 0) {
				*_gcd *= i;
				*a /= i;
				*b /= i;
				i--;
			}
			if (*a == 1 || *b == 1) {
				break;
			}
		}
	}
}

void first() {
	int* n = new int;
	cin >> *n;

	string* s = new string;
	cin >> *s;

	bool* zeros = new bool(false);
	bool* ones = new bool(false);

	for (int i = 0; i < 2 * *n - 1; i++) {
		if (s->at(i) == '0') {
			*zeros = true;
		}
		else {
			*ones = true;
		}
		if (*zeros && *ones) { break; }
	}

	string* s2 = new string;

	if (*zeros && *ones) {
		for (int i = 0; i < *n; i++) {
			if (i == 0) {
				s2->push_back(s->at(0));
			}
			else if (i == *n - 1) {
				s2->push_back(s->at(2 * *n - 2));
			}
			else {
				if (i % 2 == 0) {
					s2->push_back('0');
				}
				else {
					s2->push_back('1');
				}
			}
		}
	}
	else if (*zeros && !*ones) {
		for (int i = 0; i < *n; i++) {
			s2->push_back('0');
		}
	}
	else if (*ones && !*zeros) {
		for (int i = 0; i < *n; i++) {
			s2->push_back('1');
		}
	}

	cout << *s2 << endl;

	delete s;
	delete n;
	delete ones;
	delete zeros;
	delete s2;
}

void print(char* s, int* size) {
	for (int i = 0; i < *size; i++) {
		cout << s[i];
	}
	cout << endl;
}

int _ceil(int* first, int* second) {

	if (*first % *second != 0) {

		return *first / (*second);

	}
	else {

		return *first / (*second) + 1;

	}

}

int main()
{

	int* a = new int;
	int* b = new int;
	int* minute = new int(0);

	cin >> *a >> *b;

	while (*a > 0 && *b > 0) {

		if (*a == 1 && *b == 1) { break; }

		if (*a > * b) {

			*b += 1;
			*a -= 2;
			*minute += 1;

		}

		else {

			*b -= 2;
			*a += 1;
			*minute += 1;

		}

	}

	cout << *minute;

	delete a, b, minute;

}

#include <bits/stdc++.h>
using namespace std;
int maxn=1;
const int N=1005;
bool f[N][N];
void find(int a,int b,int sum)
{
    if(a<2&&b<2)
    {
        maxn=max(maxn,sum);
        return;
    }
    if(f[a][b]) return;
    f[a][b]=1;
    if(a>1) find(a-2,b+1,sum+1);
    if(b>1) find(a+1,b-2,sum+1);

}
int main()
{
    int a,b;
    cin>>a>>b;
    memset(f,0,sizeof(f));
    find(a,b,0);
    maxn=maxn-1;
    cout<<maxn<<endl;
    return 0;
}

 #include <iostream>

using namespace std;

int main()
{
	int a, b;
	cin>>a>>b;
	int step = 0;
	while((a>=2 || b>=2) && (a>0 && b>0)){

		step++;
		if(a>b){
			a -= 2;
			b += 1;
		}
		else{
			b -= 2;
			a += 1;
		}
		//cout<<a<<' '<<b<<endl;

	}

	cout<<step<<endl;
}

// 3 5
// 4 3
// 2 4
// 3 2
// 1 3
// 2 1
//
#include "iostream"
using namespace std;
int main()
{
  int x,y,i=0;
  cin >> x;
  cin >> y;
  while (x > 0 && y > 0)
  {
    i++;
    if (x==1 && y==1)
    {
      i--;
      break;
    }
    if (x==2 && y == 2)
    {
      break;
    }
    if (x<=y)
    {
      x++;
      y-=2;
      continue;
    }
    if (y<x)
    {
      y++;
      x-=2;
      continue;
    }
  }
  cout << i;
  return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//#define debug
#ifdef debug
	#define PR(x) cout << #x": " << x << "\t";
	#define vPR(v) for(auto i: v) cout << i << " " << endl;
	#define vvPR(v) for(auto i: v){ for(auto j: i) cout << j << " "; cout << endl;}
#endif
#define INFLL 9223372036854775807
#define INFIN 2147483647
#define SIZE 100001
#define M 1000000007
#define pb push_back
#define ppb pop_back
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define mp make_pair
#define fi first
#define se second
#define s(v) v.begin()
#define e(v) v.end()
#define PII pair<int, int>
#define PLL pair<long, long>
#define fbo(s, i) s.find_by_order(i)
#define ook(s, x) s.order_of_key(x)
#define aREP(i, a, b) for(int i=a; i<b; i++)
#define rREP(i, a, b) for(int i=a; i>=b; i--)
#define eREP(i, a, b) for(int i=a; i<=b; i++)
#define vREP(i, a, b) for(auto i=a; i!=b; i++)
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//---------------------------------------

int main()
{
	sync;
	int a, b, x=0;
	cin >> a >> b;
	int *c=(a<b)? &a: &b, *d=(a<b)? &b: &a;
	while(!((a==1 && b==2) ||  (b==1 && a==2) || (a==2 && b==2) || (a==1 && b==1)))
	{
		*c+=*d/2;
		x+=*d/2;
		*d%=2;
		if(*d==0)
		{
			*d+=2;
			(*c)--;
			x--;
		}
		swap(c, d);
	}
	cout << ((a==1 && b==1)? 0: x+1);
}

//---------------------------------------

/*
NOTE TO SELF/READER:
••••••••••••••••••••••••••••••••
•be careful with bounds.
•be careful with special/edge cases (n=1, n=0).
•watch out for leaking(%M).
•watch out for declaration of memory in excess
•declare large arrays in heap
•be careful using arrays with n>1 dimensions (wrt memory limit)
•in large arrays, maybe int could suffice where youre using long long(for runtime error)
•think while afk during practice: stay productive afk.
•its better if you always have a problem to think about when youre taking breaks.
•write down new things right as you learn about them.

NOTE TO ANANYA:
••••••••••••••••••••••••••••
I really adore you, and I know you really like hearing it from me.
Oh jaan how terribly I've missed you.
Just know that im always thinking of you, no matter what I do..
*/

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int count=0;
	if(a<=2&&b<=2)
	{
		if((a==1&&b==2)||(a==2&&b==1)||(a==2&&b==2))
		count++;
		cout<<count;
		return 0 ;
	}
	while(1)
	{
		if(a<=2&&b<=2)
		{
			if(a>=1&&b>=1)
			count++;
			break;
		}

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

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <sstream>
using namespace std;
int main(){
	int a1,a2,count=0;
	cin >> a1 >> a2;
	while(a1 > 0 && a2 > 0){
		if(a1 >= a2){
			a2++;
			a1-=2;
		}
		else{
			a1++;
			a2-=2;
		}
		if(a1 < 0 || a2 < 0)
			break;
		count++;
	}
	cout << count << '\n';
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main ()
{
	int a,b;
	cin>>a>>b;
	int t=0;
	if(a==1&&b==1) cout<<0;
	else{
		while(a>0&&b>0){
			t++;
			if(a>b){
				a-=2;
				b++;
			}else{
				a++;
				b-=2;
			}
		}
		cout<<t;
	}
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a,b,t;
int memo[202][202];
int bkt(int a, int b)
{
    if(a<=0 || b<=0)
        return 0;
    if(!memo[a][b])
        memo[a][b]=max(bkt(a-2,b+1),bkt(a+1,b-2))+1;
    return memo[a][b];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a>>b;
    if(a==1 && b==1)
        cout<<0;
    else
        cout<<bkt(a,b);
    return 0;
}

#include<iostream>
using namespace std;

int main()
{
	int a1, a2,cnt=0;
	cin >> a1 >> a2;
	if (a1 == 1 && a2 == 1)
	{
		cout << cnt << endl;
		//system("pause");
		return 0;
	}
	while (a1 > 0 && a2 > 0)
	{
		if (a1 > a2)
		{
			a1 = a1 - 2;
			a2 += 1;
		}
		else
		{
			a1 += 1;
			a2 -= 2;
		}
		cnt++;
	}
	cout << cnt << endl;
	//system("pause");
	return 0;
}

#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <deque>
#include <map>
#include <string>
#include <bitset>
#include <complex>
#include <memory>
#include <utility>

using namespace std;

typedef long long ll;
typedef double long dl;
typedef string str;
typedef vector<ll> vll;
typedef vector<int> vi;

#define FO(i,n) for(int (i)=0; (i)<(n); (i)++)
#define nmax 100100
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair

const double PI = 3.14159265358979323846;

int main()
{
    int a, b, r=0;
	cin>>a>>b;
if(a==1 && b==1)
{
cout<<0;
return 0;}
	while(a>0 && b>0)
		if(a>b) if(a>2) while(a>2) a-=2, b++, r++; //, cout<<a<<' '<<b<<endl;
		else{r++; break;}
		else if(b>2) while(b>2) b-=2, a++, r++;//, cout<<a<<' '<<b<<endl;
		else {r++; break;}

	cout<<r;
	//system("pause");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    int sum=0;
    cin>>a>>b;
    if(a==b&&b==1){
        cout<<0<<endl;
        return 0;
    }
    while(a>0&&b>0){
        if(b<a){
            b++;
			a-=2;
        }
        else{
            a++;
			b-=2;
        }
        sum++;
    }
    cout<<sum<<endl;
    return 0;
}

#include<iostream>
using namespace std;
int main(){
	int a,b,s=0;
	cin>>a>>b;
	if(a==b&&b==1){
	cout<<0;
	return 0;}
	while(a>0&&b>0){
		if(a<b) { a++; b-=2;}
		else {b++; a-=2;}
		s++;
	}
	cout<<s;
	return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <iomanip>
#include <cstdlib>
#include <fstream>
#include <queue>
#include <cstdio>
#include <set>
#include <cstring>
#include <string>
#include <algorithm>
#define x first
#define y second
#define modu 1000000007
#define ll long long
#define ull unsigned long long
#define pp pair<int,int>
#define ss short
using namespace std;
int i,j,mini=1000000000,p,d,n,m,k,ok,a,b,ul,c,op,maxi,x,y;
ll int rasp;
map<pair<int,int> , int> same;
map<int,int> xx,yy;
int main()
{
#ifndef ONLINE_JUDGE
    ifstream cin(".in");
   /// ofstream cout(".out");
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b;
    while(a > 1 || b > 1 )
    {
        if(a<1 || b<1)
            break;

        if(a > b)
            a-=2,b++;
        else
            b-=2,a++;
        c++;
    }

    cout<<c;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    int ans=0;
    cin>>a>>b;
    if(a==b&&b==1)
    {
        cout<<0<<endl;
        return 0;
    }
    while(a>0&&b>0)
    {
        if(b<a)
        {
            b++;a-=2;
        }
        else
        {
            a++;b-=2;
        }
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int a1,a2;
    while(scanf("%d%d",&a1,&a2)!=EOF)
    {
        int temp,mid=0,counter=0;
        temp=a1>a2?a2:a1;
        do
        {
            int min=a1>a2?a2:a1;
            mid=(a1+a2)/2;
            if(a1==1&&a2==1)
                break;
            if(min>mid)
            {
                if(temp==a1)
                {
                    a1+=1;
                    a2-=2;
                    temp=a1;
                }
                else if(temp==a2)
                {
                    a2+=1;
                    a1-=2;
                    temp=a2;
                }
            }
            else
            {
                if(a1==min)
                {
                    a1+=1;
                    a2-=2;
                    temp=a1;
                }
                else if(a2==min)
                {
                    a2+=1;
                    a1-=2;
                    temp=a2;
                }
            }
            counter++;

        }while(a1>0&&a2>0);
        cout<<counter<<endl;
    }
    return 0;
}

#include <iostream>
#include <cstdio>

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

using namespace std;

int Min(int a, int b)
{
	if (a < b) return a;
	else if (a == b) return a;
	else return b;
}
int Max(int a, int b)
{
	if (a > b) return a;
	else if (a == b) return b;
	else return b;
}
int main()
{
	int a, b, max, min, res = 0;
	cin >> a >> b;
	min = Min(a, b);
	max = Max(a, b);
	while ((max > 0) && ( max > 0))
	{
	    if ((min != 1) || (max != 1))
		    res++;
		min = Min(a, b);
		max = Max(a, b);
		min++;
		max = max - 2;
		a = min, b = max;
	}
	cout << res;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int sw;
int dfs(int a, int b){
	if (a<=1 && b<=1) return 0;
	else if (a<=2 && b<=2) return 1;
	if (a > b) return dfs(a-2, b+1)+1;
	else return dfs(a+1, b-2)+1;
}
int main(void){
	int a, b;
	cin >> a >> b;
	cout << dfs(a, b) << endl;
}

#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define MAX_INT 1e18

using namespace std;

int main(){

	ll x,y;
	cin>>x>>y;
	ll res=0;
	while(x>1 || y>1){
		if(x==0 || y==0)
			break;
		if(x>y){
			y++;
			x=x-2;
			res++;
		}
		else{
			x++;
			y=y-2;
			res++;
		}
	}
	cout<<res<<endl;
}

#include<bits/stdc++.h>
using namespace std;
int a,b,ans=0;
int main(){
	cin>>a>>b;
	if(a==1&&b==1){
		cout<<0;
		return 0;
	}
	while(a>0&&b>0){
		if(a>b){
			b+=1;
			a-=2;
		}
		else{
			b-=2;
			a+=1;
		}
		ans++;
	}
	cout<<ans;
}

#include <iostream>
#include<cstdio>
using namespace std;

int main()
{
    int m,n;
    while(~scanf("%d%d",&m,&n))
    {
        int ans=0;
        while(m>0&&n>0)
        {
            if(m==1&&n==1)
            {
                break;
            }
            if(m>n)
            {
                m=m-2;
                n++;
            }
            else
            {
                n=n-2;
                m++;
            }
            ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int m,n;
    int min=0;
    scanf("%d %d",&m,&n);
    while( m>0 && n>0 )
    {
        if(m==1 && n==1)
            break;
        if(m>n)
        {
            m=m-2;
            n++;
        }
        else if(m<n)
        {
            m++;
            n=n-2;
        }
        else if(m==n)
        {
            m++;
            n=n-2;
        }
        min++;
    }
    printf("%d\n",min);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(x) __builtin_popcount(x)
#define sc1ll(x) cin>>x
#define sc2ll(x,y) cin>>x>>y
#define sc3ll(x,y,z) cin>>x>>y>>z
vector< vector<ll> > visited(125,vector<ll>(125,0));
vector<vector<ll> > arr(125,vector<ll>(125,0));
ll solve(ll a,ll b)
{
    if(a>b)
        swap(a,b);
    if(a<=0)
        return 0;
    if(visited[a][b]==1)
        return arr[a][b];
    arr[a][b]=max(solve(a-2,b+1),solve(a+1,b-2))+1;
    visited[a][b]=1;
    return arr[a][b];
}
int main()
{
    ll test,i,j,num,a,b,ans;
    cin>>a>>b;
    if(a==1&&b==1)
        ans=0;
    else
    {
        ans=solve(a,b);

    }
    cout<<ans;

}

#include <stdio.h>
#include <iostream>
#include <vector>
#include <sstream>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <cstdlib>

using namespace std;

int m[1000][1000] = { 0 };
int max(int a, int b)
{
	return (a < b) ? b : a;
}

int rec(int a, int b)
{
	if (a <= 1 && b <= 1) {
		return 0;
	}

	if (a <= 0 || b <= 0) {
		return 0;
	}

	if (m[a][b] > 0) {
		return m[a][b];
	}

	int aa = rec(a + 1, b - 2);
	int bb = rec(a - 2, b + 1);
	int cc = rec(a - 2, b - 2);
	m[a][b] = max(aa, max(bb, cc)) + 1;
	return m[a][b];
}

int main()
{
	int a, b;

	cin >> a >> b;
	cout << rec(a, b);
}

#include <bits/stdc++.h>
#define N 400

using namespace std;

int res;
int dp[N][N][N] ;

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

int main()
{
    ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;

    memset(dp,-1,sizeof dp) ;

    int n , m ;
    cin>> n >> m ;
    res=0 ;
    rec(n,m,0) ;
    cout<<res ;

    return 0;
}

/*   Kayrat Isaev   */

#include<bits/stdc++.h>
#define pi 3.141592653589793

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

ll a , b , k;

int main()
{
	ll x , y , z;
    cin >> a >> b;
    while(1)
    {
    	if((a == 0) || (b == 0))
    	{
    		cout << k;
    		return 0;
    	}
    	else if(a == 1)
    	{
    		if((a == 1) && (b == 1))
    		{
    			cout << 0;
    			return 0;
    		}
    		else
    		{
      		a++;
    		b -= 2;
    		}
    	}
    	else if(b == 1)
    	{
    		if((b == 1) && (a == 1))
    		{
    			cout << 0;
    			return 0;
    		}
    		else
    		{
    		b++;
    		a -= 2;
    		}

    	}
    	else if(a == 2 && b > 2)
    	{
    		a++;
    		b -= 2;
    	}
    	else if(b == 2 && a > 2)
    	{
    		b++;
    		a -= 2;
    	}
    	else
		{
    	a++;
    	b -= 2;
        }
		k++;

		if(a > b)swap(b , a);
    }
    return 0;
}

#include <cstdio>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int cnt=0;
    if (a==1&&b==1) {
        puts("0");
    }
    else
    {
        while (a>0&&b>0) {
            if (a>=b) {
                a-=2;b++;
            }else
            {
                a++;b-=2;
            }
            ++cnt;
        }
        printf("%d\n",cnt);
    }
}

#include <stdio.h>
#include <iostream>
#include <vector>
#include <sstream>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <cstdlib>

using namespace std;

int m[1000][1000] = { 0 };
int max(int a, int b)
{
	return (a < b) ? b : a;
}

int rec(int a, int b)
{
	if (a <= 1 && b <= 1) {
		return 0;
	}

	if (a <= 0 || b <= 0) {
		return 0;
	}

	if (a >= 1000 || b >= 1000) {
		return 0;
	}

	if (m[a][b] > 0) {
		return m[a][b];
	}

	int aa = rec(a + 1, b - 2);
	int bb = rec(a - 2, b + 1);
	int cc = rec(a - 2, b - 2);
	m[a][b] = max(aa, max(bb, cc)) + 1;
	return m[a][b];
}

int main()
{
	int a, b;

	cin >> a >> b;
	cout << rec(a, b);
}

#include<iostream>
using namespace std;
int main()
{
	int m,n,i,c;
	cin >> m>>n;
	for (i=0;(m >= 1 && n >= 2) || (m >= 2 && n >= 1);i++)
	{
		if (m <= n)
		{
			m += 1;
			n -= 2;
		}
		else if (m>n)
		{
			m -= 2;
			n += 1;
		}
	}
	cout << i<<"\n";
	return 0;
}

#include <iostream>
#include <queue>
using namespace std;

bool visited[1000][1000];
int main() {
    int a, b;
    cin >> a >> b;

    if( a <= 1 && b <= 1) {
        cout << 0 << endl;
        return 0;
    }

    queue< pair<int, pair<int, int>> > q;
    q.push({0, {a, b}});

    int M = 0;
    while(!q.empty()) {
        int x = q.front().second.first;
        int y = q.front().second.second;
        int d = q.front().first;
        q.pop();

        int nx, ny;

        nx = x-2, ny = y+1;
        if( nx < 0 ) {
            if( d > M )
                M = d;
        }
        else {
            if( !visited[nx][ny]) {
                visited[nx][ny] = true;
                q.push( {d+1, {nx, ny}});
            }
        }

        nx = x+1, ny = y-2;
        if( ny < 0)
        {
            if( d< M )
                M = d;
        }
        else
        {
            if( !visited[nx][ny] ) {
                visited[nx][ny] = true;
                q.push( {d+1, {nx, ny}});
            }
        }
    }

    cout << M-1 << endl;

    return 0;
}

#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<list>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	int s;
	s=0;
	cin>>a>>b;
	if(a==1&&b==1)
	{
		cout<<0;
	}
	else
	{

	while(a>0&&b>0)
	{
		if(a>=b)
		{
			a-=2;
			b+=1;
			s+=1;
		}
		else
		{
			b-=2;
			a+=1;
			s+=1;
		}
	}

	cout<<s;
	}
	return 0;
}

#include <iostream>
using namespace std;
int longtime(int a,int b)
{
    if(a<=0||b<=0||(a==1&&b==1)) return 0;
    else if(b==1||b==2) return 1+longtime(a-2,b+1);
    else return 1+longtime(a+1,b-2);
}
int main()
{
    int power1,power2;
    cin>>power1>>power2;
    int long_time=longtime(power1,power2);
    cout<<long_time<<endl;
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <tuple>
#include <cassert>

using namespace std;

#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

class DSU {
private:
	vector<int> ids;
	vector<int> h;
public:
	DSU(int n) {
		ids.resize(n);
		h.resize(n);
		for (int i = 0; i < n; i++) {
			ids[i] = i;
			h[i] = 1;
		}
	}
	int getRoot(int ind) {
		if (ids[ind] != ind)return getRoot(ids[ind]);
		return ind;
	}
	bool connected(int ind1, int ind2) {
		return getRoot(ind1) == getRoot(ind2);
	}
	void connect(int ind1, int ind2) {
		if (connected(ind1, ind2))return;
		int r1 = getRoot(ind1);
		int r2 = getRoot(ind2);
		if (h[r1] > h[r2]) {
			ids[r2] = r1;
			h[r1] += h[r2];
		}
		else {
			ids[r1] = r2;
			h[r2] += h[r1];
		}
	}
	int idCount() {
		set<int> check;
		for (auto i : ids)check.insert(i);
		return len(check);
	}
};

ll gcd(ll a, ll b) {
	while (b != 0) {
		ll t = a % b;
		a = b;
		b = t;
	}
	return a;
}

ll lcd(ll a, ll b) {
	return a / gcd(a, b)*b;
}

int sgn(int n) {
	if (n < 0)return -1;
	if (n > 0)return 1;
	return 0;
}

int sgn(ll n) {
	if (n < 0LL)return -1;
	if (n > 0LL)return 1;
	return 0;
}

inline int nextInt() {
	int n;
	scanf("%d", &n);
	return n;
}

inline ll nextLong() {
	ll n;
	scanf("%lld", &n);
	return n;
}

inline double nextDouble() {
	double n;
	scanf("%lf", &n);
	return n;
}

inline string nextLine() {
	static char ______________buffer[1000005];
	fgets(______________buffer, 1000000, stdin);
	string res = ______________buffer;
	return res;
}

inline char nextChar() {
	char n;
	scanf("%c", &n);
	return n;
}

inline string next() {
	static char ______________buffer[1000005];
	scanf("%s", ______________buffer);
	string res = ______________buffer;
	return res;

}

int mod = 998244353;

double const PI = 3.14159265359;

int main() {

	int n = nextInt();
	int m = nextInt();

	ll res = 0;

	while (n > 0 && m > 0) {
		if (m - 2 > 0 ) { n++; m -= 2; }
		else if(n - 2> 0) { m++; n -= 2; }
		else {
			res++;
			break;
		}
		res++;

	}
	printf("%lld", res);
#ifdef _DEBUG
	printf("\nEND\n");
	while (1);
#endif
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int a1, a2;
int fun(int a1, int a2,int sum)
{
	a1 -= 2;
	a2 += 1;
	if (a2 >= 100)
		a2 = 100;
	sum++;
	if (a1==0||a2==0||(a1==1&&a2==1))
		return sum;
	if (a1 > a2)
		fun(a1, a2,sum);
	else fun(a2, a1,sum);
}
int main()
{
    int sum=0;
	cin >> a1>>a2;
	if (a1 > a2)
		sum=fun(a1, a2,sum);
	else sum=fun(a2, a1,sum);
	cout << sum << endl;
}

#include <cmath>
#include <iostream>
using namespace std;
int main() {
	int x, z,sum=0;
	cin >> x >> z;
	if (x != 1 && z != 1) {
		while (z > 0 && x > 0) {
			if (z >= x) { x++; z -= 2; sum++; }
			else if (z < x) { z++; x -= 2;  sum++; }
			else { continue; }
		}
		cout << sum;
	}
	else { cout << sum; }

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long i,j,m,n,p,q,r,c,mm;
set<long long>s;
int main()
{
cin>>m>>n;
if(m==1&&n==1)
{
    cout<<1;
    return 0;
}
while(n>0&&m>0)
{
    mm=min(m,n);
    //cout<<mm;
    if(m==mm)
    {
        while(n)
        {
            c++;
            m+=1;
            n-=2;
            if(n==2||n==1)
                break;
        }
    }
    else
    {
        while(m)
        {
            c++;
            n+=1;
            m-=2;
            if(m==1||m==2)
                break;
        }

    }
}
cout<<c;
}

#include <bits/stdc++.h>

/*
                     			_
  		  /\/\   __ _  __ _ ___| |__   __ _ _ __
		 /    \ / _` |/ _` |_  / '_ \ / _` | '_ \
		/ /\/\ \ (_| | (_| |/ /| | | | (_| | | | |
		\/    \/\__,_|\__, /___|_| |_|\__,_|_| |_|
 		   		      |___/
*/

#include <cmath>
#include <math.h>
#include <ctype.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

#define endl "\n"
#define _ ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fi first
#define se second
#define setp(a)  fixed << setprecision(a)
#define mp make_pair
#define pb push_back
#define sz size()
#define mst(x , y) memset(x , y , sizeof x)
#define all(x) x.begin() , x.end()
#define sqr(a) (((a) * (a)))
#define error(x) cerr << (x) << endl

#define prii pair < int , int >
#define prll pair < ll , ll >
#define Vi vector < int >
#define Vl vector < ll >
#define ll long long
#define ull unsigned long long

using namespace std;

const double pi = 3.14159265359;
const ll INF = (ll) 1e17 + 99999999;
const ll Mod = (ll) 1e9 + 7;
const ll MaXN = (ll) 1e18;
const int N = (int) 1e6 + 7;
const int MaXI = (int) 1e9;
const int Mass = (int) 2e5;

int main(){ _
	#ifdef Magzhan
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
  #endif
  int a , b , cnt = 0;
  cin >> a >> b;
  while(a > 2 || b > 2){
   	if(a < b && a < 100){
   		a ++;
   		b -= 2;
   	}
   	else if(a >= b && b < 100){
   	 	b ++;
   	 	a -= 2;
  	}
  	else{
  	 	a -= 2;
  	 	b -= 2;
  	}
  	cnt++;
  }
  cout << cnt + 1;
	return 0;
}

#include <cstdio>
#include <algorithm>

using namespace std;

int dp[401][401];

void init() {
    for (int i = 0; i <= 400; i++) {
        for (int j = 0; j <= 400; j++) {
            dp[i][j] = -1;
        }
    }
}

int solve(int a, int b) {
    if (a <= 0 || b <= 0) return 0;
    if (dp[a][b] >= 0) return dp[a][b];
    int di[2] = {-2, 1};
    int dj[2] = {1, -2};
    for (int i = 0; i < 2; i++) {
        dp[a][b] = max(dp[a][b], solve(a + di[i], b + dj[i]) + 1);
    }
    return dp[a][b];
}

int main(void) {
    int a, b;
    while (scanf("%d %d", &a, &b) == 2) {
        init();
        printf("%d\n", solve(a, b));
    }
    return 0;
}

#include <iostream>
using namespace std;
int main(){

    int Joystick_one, Joystick_two,count=0;
    cin>>Joystick_one>>Joystick_two;
    if(Joystick_one<=1&&Joystick_two<=1)
    {
        cout<<0;
    }
    else{
        while(Joystick_two>0&&Joystick_one>0)
    {
    if(Joystick_one>=Joystick_two)
    {
        Joystick_one-=2;
        Joystick_two++;
        count++;
    }
    else if(Joystick_one<=Joystick_two)
    {

        Joystick_two-=2;
        Joystick_one++;
        count++;
    }}}
    cout<<count;
}

#include<bits/stdc++.h>
using namespace std;

const int MAX = 1e5+5;
 bool visited[MAX];
int main()
{
    long long int n;
    string s2;
    stack<char>stk;
    vector<int>vec;
    set<char>s;
    map<string,int>mp;
    int var[MAX]={0};
    string s1[]={"Sheldon", "Leonard", "Penny", "Rajesh","Howard"};
    long long int t,m,cnt=0,x=0,y=1,a,b;
    cin>>n>>m;
    if(n<=2 || m<=2) {
        cout<<0<<endl;
        return 0;
    }
    string ss,st;
    int arr[n+5];
    while(1){
              if(x==1) break;
         if(n>=m){
         while(n>=m){
            m+=1;
            n-=2;
            cnt++;
            if(n==0 || m==0) x=1;
           // cout<<cnt<<" cnt "<<endl;
            //cout<<n<<" n "<<m<<" m"<<endl;
        }
         }
         else{
        while(m>n){
            m-=2;
            n+=1;
            cnt++;
            //cout<<cnt<<" cnt "<<endl;
            if(n==0 || m==0) x=1;;
            //cout<<n<<" n "<<m<<" m"<<endl;
        }
         }

    }
    cout<<cnt<<endl;

}

#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, ans = 0;
	cin >> a >> b;
	while(min(a, b) >= 1){
		if(a <= b) a++, b-=2;
		else b++, a-=2;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    if (max(a, b) == 1) {
        cout << 1 << endl;
        return 0;
    }
    while (min(a, b) > 0) {
        if (a < b) {
            a++;
            b-=2;
        }
        else {
            a-=2;
            b++;
        }
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

#include <stdio.h>
int a, b;
int d[304][304][504];
int maxx = 0;
void back(int a, int b, int cnt)
{
	if (a <= 1 || b <= 1)
	{
		if (cnt > maxx)maxx = cnt; return;
	}
	if(d[a][b][cnt]<cnt) d[a][b][cnt] = cnt;
	else return;
	back(a - 2, b + 1, cnt + 1);
	back(a + 1, b - 2, cnt + 1);
}
int main()
{
	scanf("%d %d", &a, &b);
	back(a, b,1);
	printf("%d", maxx-1);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int maxn = 0 ;
bool vis[1001][1001] ;
void f(int a, int b, int sum  )
{
	if (a<=0 || b<=0) {
		if (sum>maxn) maxn = sum ;
		return ;
	}
	if(vis[a][b] == 1) return ;
	vis[a][b ]  = 1 ;
	f(a+1, b-2, sum+1) ;
	f(a-2,b+1, sum +1) ;

}
int main()
{
	int a, b ;
	cin>> a>> b;

	f(a,b, 0 ) ;
	cout<< maxn <<endl;
	return 0 ;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
  ll n, m, otv = 0; cin >> n >> m;

    if (n == 1 && m == 1) {
        while (m > 0 && n > 0) {
            if (n > m) {
                m ++;
                n -= 2;
                otv++;
            } else {
                m -= 2;
                n++;
                otv++;
            }
        }
    }
    cout << otv;
}

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int k[101][101];
int main()
{
	int a,b;
	cin>>a>>b;
	cout<<k[a][b];
	return 0;
}

#include<iostream>
using namespace std;

int a,b;

int main(){

   cin>>a>>b;

   int j=min(a,b),cnt=0;

    if(j==a){
             j=1;
             }

    else{
         j=2;
         }

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

           if(b-2<=1 && j==1){
                    j++;
                    }

           else if(a-2<=1 && j==2){
                j=1;
                }

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

           cnt++;

            }

    cout<<cnt;

    return 0;
    }

#include <iostream>
#include<iomanip>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
	int a1, a2, cont = 0;
	cin >> a1 >> a2;
	while (a1 > 0 && a2 > 0||(a1 > 1 && a2 > 1)){
		if (a1 < a2){
			a1++;
			a2 -= 2;
			cont++;
		}
		else{
			a2++;
			a1 -= 2;
			cont++;
		}
	}
	cout << cont << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
    int x, y;
    cin >> x >> y;
    int cnt = 0;
    while(max(x, y) <= 1){
        int z = min(x, y);
        if(z == x) x++, y-= 2;
        else
            y++, x -= 2;
        cnt++;
    }
    cout << cnt << endl;
}

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;

int n, m, a, b;

int main(){

cin>> n >> m;

a = min(n, m);

b = max(n, m);

for(int i = 1; ; i++){

if(a == 100 && b == 100){

a -= 1;

}

else if(a + 1 <= 100){

a++;

b -= 2;

if(a == 100 || b == 1 || b - 2 == 0) swap(a, b);

}

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

cout <<i;

return 0;

}

}

return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int a1 , a2;
    cin >> a1 >> a2;

    int t=0;

    while(a1 && a2)
    {
      if(a1>a2)
        swap(a1,a2);
      if(a1==a2 && a1== 1)
        a1++;
      a2-=2;
      t++;
    }
    cout<<t;

}

#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <climits>
#include <cassert>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define REP(i, n) for (int i=0;i<n;++i)
#define FOR(i, a, b) for (int i=a;i<b;++i)
#define DWN(i, b, a) for (int i=b-1;i>=a;--i)
#define REP_1(i, n) for (int i=1;i<=n;++i)
#define FOR_1(i, a, b) for (int i=a;i<=b;++i)
#define DWN_1(i, b, a) for (int i=b;i>=a;--i)
#define REP_N(i, n) for (i=0;i<n;++i)
#define FOR_N(i, a, b) for (i=a;i<b;++i)
#define DWN_N(i, b, a) for (i=b-1;i>=a;--i)
#define REP_1_N(i, n) for (i=1;i<=n;++i)
#define FOR_1_N(i, a, b) for (i=a;i<=b;++i)
#define DWN_1_N(i, b, a) for (i=b;i>=a;--i)
#define PB push_back
#define MP(A, B) make_pair(A, B)

typedef long long LL;
typedef double DB;

const int MOD = int(1e9) + 7;
const DB PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

template<class T> inline void OT(const T &);
template<class T0, class T1> inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}
template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}
template<class T> inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));}
template<class T> inline T min(T a, T b, T c, T d, T e){return min(min(min(a,b),min(c,d)),e);}
template<class T> inline T max(T a, T b, T c, T d, T e){return max(max(max(a,b),max(c,d)),e);}
template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));}
template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}
template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);}
template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x),FLC(A2, x), FLC(A3, x);}
template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5&A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4&A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);}
template<class T> inline T& RDD(T &x){
    char c;while(c=getchar(),c!='-'&&!isdigit(c));
    if (c=='-'){x='0'-(c=getchar());while(isdigit(c=getchar()))x=x*10+'0'-c;}
    else{x=c-'0';while(isdigit(c=getchar()))x=x*10+c-'0';}
    return x;
}
/* .................................................................................................................................. */

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
        //freopen("out.txt", "w", stdout);
    #endif
    int a, b, tmp;
    while(scanf("%d%d", &a, &b) != EOF)
    {
        int ans = 0;
        if(a > b)
        {
            tmp = a;
            a = b;
            b = tmp;
        }
        while(a > 0 && b > 0)
        {
            if(b <= 2)
            {
                tmp = a;
                a = b;
                b = tmp;
            }
            ++a;
            b -= 2;
            ++ans;
        }
        printf("%d\n", ans);
    }
    return 0;
}

/*input
19 19
*/
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define pii pair<long long,long long>
#define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)
#define PI 3.14159265
#define ll long long
#define ff first
#define ss second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define INF 1000000009
#define mod 1000000007
vector <ll> v;
int main()
{
	std::ios::sync_with_stdio(false);
	ll a1,a2;
	cin>>a1>>a2;
	ll ans = 0;
	if(a1==a2)
		ans = a1+a2-3;
	else
		ans = a1+a2-2;
	/*while(a1>=1 && a2>=1)
	{
		cout<<a1<<" "<<a2<<endl;
		if(a1<a2)
			swap(a1,a2); // a1 is always bigger
		ll t = (a1-1)/2;
		ans = ans + (a1-1)/2;
		if(a1==2)
			a1 = 0;
		a1 = a1 -t*2;
		a2 = a2 + t;
	}*/
	cout<<ans<<endl;
	return 0;
}

#include<stdio.h>

int main ()
{
    int a,b;
    int t=0;
    scanf ("%d",&a);
    scanf ("%d",&b);
    if (a>b)
    {
            int tmp;
            tmp=a;
            a=b;
            b=tmp;
     }
    while (a<=b && a!=0 && b!=0 && a>1 && b>1)
    {

          a=a+1;
          b=b-2;
          t++;
          if(a>b)
          {
                  int tmp;
                  tmp=a;
                  a=b;
                  b=tmp;
                  }
          if(a<=0 || b<=0)
                  break;
          }
    printf ("%d",t);

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int a1 , a2;
    cin >> a1 >> a2;

    int l=max(a1,a2);
    int s=min(a1,a2);
    int n = 0;

    while(l>s)
    {
        if(l==1 && l==s)
        break;
        l=l-2;
        s=s+1;
        n++;
    }
    int t =n+2*max(l,s)-3;
    if(t<0)
        cout<<0;
    else
        cout<<t;
}

#include <bits/stdc++.h>
#define sum(x) x*(x+1)/2
#define iint(x) int(x)-97
#define foor(x) for(int i=0;i<x;i++)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;

int main()
{
    ull a,b;
    cin>>a>>b;
    cout<<max(a,b)+1<<endl;
    return 0;
}

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#define Rep(i,n) for(int i = 1; i <= n ; i ++)
#define RepG(i,x) for(int i = head[x] ;~ i ; i = edge[i].next)
#define Rep_d(i,n) for(int i = n ; i > 0 ; i --)
#define Rep_0(i,n) for(int i = 0 ; i < n ; i ++)
#define RD(i,x,n) for(int i = x; i <= n ; i ++)
#define CLR(a,b) memset(a,b,sizeof(a))
#define rson x << 1 | 1,mid + 1,r
#define lson x << 1,l ,mid
#define RDD(i,x,n) for(int i = x; i >= n; i --)
#define fl edge[i].f
#define vfl edge[i^1].f
#define v edge[i].to
using namespace std;
const int inf = 1 << 30;
typedef long long ll;
int read(){
	char ch = getchar();
	while(ch < '0' || ch > '9')ch = getchar ();
	int x = 0;
	while(ch >= '0' && ch <= '9')x = 10 * x + ch - '0',ch = getchar ();
	return x;
}
int n,m,Maxn = 0;
int main (){
	n = read(), m = read();
	while(n > 0 && m > 0){
		if(n > m)swap(n,m);
		if(n != 100)n++;
		m -= 2;
		Maxn ++;
	}
	printf("%d\n",Maxn);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
int main() {
    ios_base::sync_with_stdio(false), cin.tie(false);
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    while(a > 0 && b > 0) {
        if(a > b) a -= 2, b ++;
        else b -= 2, a ++;
        cnt ++;
    }
    cout << cnt << endl;
    cout.flush();
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>

using namespace std;

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

vector<int> v;

char e[100];

int main()

{
	int n,m;
	cin>>n>>m;
	int k=0;
	while(n && m)
	{
		if(n>m) swap(n,m);
		if(n!=100) n++;
		m-=2;
		k++;
	}
	cout<<k;
	return 0;

}

#include <iostream>
using namespace std;

int main()
{
	int a, b, x;
	cin >> a >> b;
	for (int i = 0; i <10000; i++)
	{
		if (((a>0) && (b>0)) && ((a==1) && (b==1)))
		{
			if (a > b)
			{
				b = b + 1;
				a = a - 2;
			}
			else
			{
				a = a + 1;
				b = b - 2;
			}

		}
		else
		{
			cout << i ;
			break;
		}
	}

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(x) __builtin_popcount(x)
#define sc1ll(x) cin>>x
#define sc2ll(x,y) cin>>x>>y
#define sc3ll(x,y,z) cin>>x>>y>>z
ll maxi_sum(ll a,ll b)
{
    ll sum=0;
    while((a!=0)&&(b!=0))
    {
        sum++;
        if((abs(a-b)>2)&&(a>2)&&(b>2))
        {
            if(a>b)
                {
                    a+=1;
                    b-=2;
                }
                else
                {
                    b+=1;
                    a-=2;
                }
        }
        else
        {
            if(a==b)
            {
                a+=1;
                b-=2;
            }
            else if(a>b)
            {
                b+=1;
                a-=2;
            }
            else
            {
                a+=1;
                b-=2;
            }
        }
    }
    return sum;
}
int main()
{
    ll test,i,j,num,a,b;
    cin>>a>>b;
    ll ans;
        ans=maxi_sum(a,b);
    cout<<ans;

}

using namespace std;
#include <bits/stdc++.h>

int main()
{
    int a, b;
    cin >> a >> b;
    if (abs(a - b) % 3 == 0)
    {
        cout << (a + b - 3) << endl;
    }
    else
    {
        cout << a + b - 2 << endl;
    }
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(x) __builtin_popcount(x)
#define sc1ll(x) cin>>x
#define sc2ll(x,y) cin>>x>>y
#define sc3ll(x,y,z) cin>>x>>y>>z
ll find_ans(ll a,ll b)
{
    ll sum=0;
    while(a>0&&b>0)
    {
        sum+=1;
        if((a==b)&&a>2)
        {
            a+=1;
            b-=2;
        }
        else
        {
            if(a>=2)
            {
                if(b<=2)
                {
                    b+=1;
                    a-=2;
                }
                else
                {
                    a+=1;
                    b-=2;
                }
            }
            else if(b>=2)
            {
                if(a<=2)
                {
                    a+=1;
                    b-=2;
                }
                else
                {
                    b+=1;
                    a-=2;
                }
            }
            else
            {
                if(a>=b)
                {
                    a+=1;
                    b-=2;
                }
                else
                {
                    a-=2;
                    b+=1;
                }
            }
        }
    }
    return sum;
}
int main()
{
    ll test,i,j,num,a,b;
    cin>>a>>b;
    ll ans=find_ans(a,b);
    cout<<ans;

}

/*9ulg*/
#include<stdio.h>
int s[3];
int ans=0;
int anchor;
void myCalc()
{
	ans++;
	s[anchor]++;
	s[!anchor]-=2;
	if (s[!anchor]<=2)
		anchor=(!anchor);

	if (s[0]<=0||s[1]<=0)
		printf("%d\n",ans);

	else
		myCalc();

}
int main()
{
	scanf("%d%d",&s[0],&s[1]);
	if (s[0]<=s[1])
		anchor=0;
	else
		anchor=1;
	myCalc();

return 0;
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <bitset>
#include <cstdlib>
#define sqr(x) (x) * (x)
#define F first
#define S second
#define pb push_back
#define sz(a) int((a).size())
#define mp make_pair

using namespace std;

const int MAXN = (int)2e6 + 1;
const int mod = (int)1e9 + 7;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long, long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

int main(){
	int a1, a2, mini, ans = 0;
	scanf ("%d %d", &a1, &a2);
	if (a1 < 3 || a2 < 3) {
		printf ("%d", 0);
		return 0;
	}
	while (true){
		if (a1 < a2){
			a1 += 1;
			a2 -= 2;
		} else {
			a1 -= 2;
			if (a2 != 100)
				a2 += 1;
		}
//		cout << a1 << ' ' << a2 << endl;
		ans++;
		if (a1 == 0 || a2 == 0)
			break;
	}
	printf ("%d", ans);
    return 0;
}

#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define mp make_pair
#define bs binary_search
#define full(a) a.begin(),a.end()
#define ff first
#define ss second
#define mem(a,x) memset(a,x,sizeof(a))
#define test int t;cin>>t; while(t--)
#define MOD 1000000007
using namespace std;

main()
{
	//freopen("input.txt","r",stdin);
	int low , high , count=0;
	cin>>low>>high;
	while(low>0&&high>0)
	{
		count++;
		if(low==1||high==1)
		{
			count--;
			break;
		}
		low+=1;
		high-=2;
		if(low>high) swap(low,high);
	}
	cout<<count+1<<endl;
}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

using namespace std;

int main()
{
	int a1,a2;
	cin >> a1 >> a2;
	int res=0, z=0;
	if(a1==a2==1){
		cout << res;
		return 0;
	}
	while(a1>0 && a2>0)
	{
		if (a1<a2)
		{
			a1=a1+1;
			a2=a2-2;
		}
		else
		{
			a2=a2+1;
			a1=a1-2;
		}
		res++;
	}
	cout << res;
	return 0;
}

#include <vector>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>
#include <cstdio>
#include <ostream>
#include <sstream>
#include <cmath>
using namespace std;
   typedef long long ll;
   int dp[250][250];
void dfs(int a, int b, int v)
{
	if( a <= 0 || b <= 0 )
		return;
	if( dp[a][b] >= v && v)
		return;
	dp[a][b] = v;
	dfs(a-2,b+1,v+1);
	dfs(a+1,b-2,v+1);
}
int main()
{
	int a, b;
	cin >> a >> b;
	dfs(a, b, 0);
	int ans = 0;
	for(int i = 0; i < 250; ++i)
		for(int j = 0; j < 10; ++j)
		ans = max(ans, max(dp[i][j], dp[j][i]));
	if( a != 1 && b != 1)
	   cout << ans + 1;
	else cout << 0;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,m,maxx,minn,cnt=0,flag=0,sum;
    cin>>n>> m;
    maxx=max(n,m);
    minn=n+m-maxx;
    while(1){
        //cout << maxx << " " << minn << endl;
        if(maxx<=0||minn<=0) break;
        if(maxx<=2&&minn<=2&&maxx>0&&minn>0){flag=1;break;}
        maxx-=2;
        minn+=1;
        sum=maxx+minn;
        maxx=max(maxx,minn);
        minn=sum-maxx;
        cnt++;
    }
    if(flag==1) cnt++;
    cout << cnt;
}

#include <bits/stdc++.h>
using namespace std;

int a1,a2,sum=0;

int time(int a,int b){
	if(a1<=0||a2<=0){
		return sum;
	}
	else{
		if(a1>a2){
			a2++;
			a1-=2;
		}
		else{
			a1++;
			a2-=2;
		}
		sum++;
		return time(a1,a2);
	}
}

int main(){
    cin>>a1>>a2;
    cout<<time(a1,a2)<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a,b,t;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a>>b;
    while(a>0 && b>0)
    {
        if(a<=2)
            if(b<=2)
                a-=2,++b;
            else
                a++,b-=2;
        else
            if(a<=2)
                b-=2,++a;
            else
                ++b,a-=2;
        ++t;
    }
    cout<<t;
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
	int x,y;
	int counter=0;
	cin>>x>>y;

	if((x==0&&y!=0)||(y==0&&x!=0)){

		cout<<1;
	return 0;

	}
	if(x==0&&y==0)
	{

		cout<<0;
	return 0;

	}
	if(x<=y)

	{
		while(x>0&&y>0){
			if(x<=y){
		x++;

		y-=2;
		counter++;
			}
			else if(y<x){

			y++;

			x-=2;
				counter++;

			}

		}

	}

	if(x>y)

	{
		while(x>0&&y>0){
			if(x<=y){
		x++;

		y-=2;
		counter++;
			}
			else if(y<x){

			y++;

			x-=2;
				counter++;

			}

		}

	}
	cout<<counter;

return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
	int m,n;
	cin>>m>>n;
	int ans = 0;
	while(m >0&&n>0){
		if(m >= n){
			m -=2;
			n++;
		}
		else{
			n -=2;
			m++;
		}
		ans++;
	}
	cout<<ans;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;

signed main()
{
    int a, b; cin >> a >> b;

    int step = 0;
    while (a > 0 && b > 0) {
        if (a > b) {
            while (a > 2) {
                a -= 2;
                b++;
                step++;
            }
        } else {
            while (b > 2) {
                b -= 2;
                a++;
                step++;
            }
        }

        if (a <= 2 && b <= 2) break;
    }

    step++;

    cout << step << endl;
}

#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <cstring>
#include <cstdlib>
#include <map>
#include <ctime>
#include <queue>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define forn(i, l, r) for(int i = l; i < r; i ++)
#define pii pair <int, int>
#define vi vector <int>
#define N 1005
#define y1 stupid_cmath
#define sz(a) (int)a.size()
#define ll long long
#define all(a) a.begin(), a.end()

const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-9;
const int maxn = (int)1e5 + 11;

int main () {
    #ifdef LOCAL
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
    #endif

    int a, b, cnt = 1;

    scanf("%d%d", &a, &b );
    if (a<b) swap(a,b);

    while (true) {
    	if (a-2>0) a-=2, b++, cnt++; else
    	if (b-2>0) b-=2, a++, cnt++; else
    	break;
    }
    cout << cnt;

	#ifdef LOCAL
    cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl;
    #endif

    return 0;
}

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <ctime>
#include <set>
#include <map>
#include <queue>
#include <memory.h>
#include <iomanip>
#define EPS 1e-7
#define INF (int)(1e+9)
#define LINF (long long)(1e+18)
#define PI acos(-1)
#define mp make_pair
#define MOD 1000000007

using namespace std;

#define NAME "test"
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

void solve(int test_number);

void pre() {
    cout.setf(ios::fixed);
    cout.precision(20);
    cerr.setf(ios::fixed);
    cerr.precision(3);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
}

void post() {
    fprintf(stderr, "\n");
    fprintf(stderr, "Execution time: %Lf", (ld) clock());
}

const int MAXN = 100100;

inline void solve(int test_number) {
	int a, b;
	scanf("%d %d", &a, &b);
	int ans = 0;
	if (b < a) swap(a, b);
	while (a != 0 && b != 0) {
		if (b % 2 != 0) ans += b / 2;
		else ans += (b - 2) / 2;
		if (b % 2 != 0) a += b / 2; else a += (b - 2) / 2;
		//if (a > 100) a = 100;
		if (b % 2 != 0) b -= (b / 2) * 2;
		else b -= (b - 2) / 2 * 2;
		if ((a == 2 && b == 2) || (a == 1 && b == 1) || (a == 1 && b == 2) || (a == 2 && b == 1)) break;
		//cout << a << ' ' << b << endl;
		swap(a, b);
	}
	printf("%d", ans + 1);
	return;
}

int main()
{
#ifdef DEBUG
    freopen(NAME ".in", "r", stdin);
    freopen(NAME ".out", "w", stdout);
#endif
    //freopen(NAME ".in", "r", stdin);
    //freopen(NAME ".out", "w", stdout);
    pre();

    int n = 1;
    for (int i = 0; i < n; i++) {
            solve(i + 1);
    }

    post();
    return 0;
}

#include <iostream>
using namespace std;
int main(){

    int Joystick_one, Joystick_two,count=0;
    cin>>Joystick_one>>Joystick_two;
    if(Joystick_one<=1||Joystick_two<=1)
    {
        cout<<0;
    }
    else if(Joystick_one>=Joystick_two)
    {
        while(Joystick_one>0){
        Joystick_one-=2;
        Joystick_two++;
        count++;}
        while(Joystick_two>0){
        Joystick_two-=2;
        Joystick_one++;
        count++;
        }
    }
    else if(Joystick_one<=Joystick_two)
    {
        while(Joystick_two>0){
        Joystick_two-=2;
        Joystick_one++;
        count++;
        }

        while(Joystick_one>0){
        Joystick_two++;
        Joystick_one-=2;
        count++;
        }
    }
    cout<<count;
}

#include<stdio.h>

int main()
{
	int x,y,t,k;
	scanf("%d",&x);
	scanf("%d",&y);
	t=0;
	k=(x+y)-3;
	t=t+k;
	printf("%d",t);

	return 0;
	}

#include <bits/stdc++.h>
  using namespace std;
  int main()
  {
  	int a1,a2;
  	cin>>a1>>a2;
  	int t=0;
  	for(;;t++)
  	{

  		if(a1>a2){
  			a1-=2;
  			a2+=1;
		  }
		  else {
		  	a1+=1;
		  	a2-=2;
		  }

		if(a1<=1&&a2<=1)break;

	  }
	  if(t>1)
  	cout<<t<<endl;
  	else cout<<0<<endl;
   }

#include<stdio.h>
#include<stdbool.h>
int main(void)
{
    int m,n;
    scanf("%d%d",&m,&n);
    bool flagm,flagn;
    flagm=flagn=false;
    if(m<=n)
    {
        flagm=true;
    }
    else
    {
        flagn=true;
    }
    int time=0;
    while(1)
    {
        if(m<=0||n<=0)break;
        time++;
        if(flagm)
        {
            m++;
            n-=2;
        }
        else if(flagn)
        {
            n++;
            m-=2;
        }
        if(m<=2)
        {
            flagm=true;
            flagn=false;
        }
        else if(n<=2)
        {
            flagn=true;
            flagm=false;
        }
    }
    printf("%d",time);
    return 0;
}

#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cstring>
#include <array>

#define F first
#define S second
#define ll long long
#define ld long double
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define sz(x) int((x).size())
#define pii pair < int, int >
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define vpii vector < pii >
#define fenwick(x) ((x) & -(x))
#define debug(x) cout << "[ " << #x << " ]: " << x << "\n";

using namespace std;

//CZY DANE POSORTOWANE, N = 0, N = 1, CZYTANIE TRESCI, < rosnaco, > malejaco

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int a, b, cnt = 0;

	cin >> a >> b;

	while (a > 0 && b > 0)
	{
		if (a > b)swap(a, b);

		b -= 2;
		a += 1;

		a = min(a, 100);
		b = min(b, 100);

		if(a > 0 && b > 0)++cnt;
	}
	cout << cnt + 1;
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
	int a, b;
	cin>>a>>b;
	int step = 0;
	while(a>0 && b>0){
		if(a>b){
			step++;
			a -= 2;
			b += 1;
		}
		else{
			step++;
			b -= 2;
			a += 1;
		}

		if(a<=2 && b<=2){
			step++;
			break;
		}
	}

	cout<<step<<endl;
}

/*
██╗  ██████╗  ██╗    ██████╗  ██████╗  ██╗ █████╗
██║ ██╔═══██╗ ██║    ╚════██╗██╔═████╗███║██╔══██╗
██║ ██║   ██║ ██║     █████╔╝██║██╔██║╚██║╚██████║
██║ ██║   ██║ ██║    ██╔═══╝ ████╔╝██║ ██║ ╚═══██║
██║ ╚██████╔╝ ██║    ███████╗╚██████╔╝ ██║ █████╔╝
╚═╝  ╚═════╝  ╚═╝    ╚══════╝ ╚═════╝  ╚═╝ ╚════╝
*/
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define r_0 return 0
#define Hello ios_base::sync_with_stdio(0);
using namespace std;
float f, flo, fload=0;
ll int a,b,c,d,e,n,m,cnt = 0, ans,cmd,i,j,x;
string s,g,o,h="hello",name;
vector< int >v;
vector< string >ve;
vector< string >vr;
int main()
{
    cin >> a >> b;
    if ( a == 1 and b == 100 )
    {
        cout << 98;
        r_0;
    }
    for ( int i=1; i<=1000; i++ )
    {
        if ( i % 2 != 0 )
        {
            a ++ ;
            b -= 2;
            cnt ++;
        }
        else if ( i % 2 == 0 )
        {
            b ++ ;
            a -= 2;
            cnt ++;
        }
        if ( a <= 0 or b <= 0 )
        {
            cout << cnt ;
            r_0;
        }
    }
    cout << cnt;
}

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

int main(){
	int a, b;
	int temp;
	while(scanf("%d%d", &a, &b)!=EOF){
		temp = a + b;
		if(abs(b - a) % 3 == 0) temp -= 3;
		else temp -= 2;
		printf("%d\n", temp);
	}
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#define mod 1000000007
#define pi 3.141592653589
#define ll  long long int
#define loop(i,n) for(ll i=0;i<n;i++)
#define loop2(i,n) for(ll i=1;i<=n;i++)
using namespace std;
int main()
{

    ll a,b;
    cin>>a>>b;
    if(a<=2&&b<=2){
        printf("1");
        return 0;
    }

    if(a==b){
        printf("%lld",(a+1));
    }
    else{
        printf("%lld",a+b-abs(a-b));
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int a, b, memo[105][105];
int recur(int x, int y){
    if(x<=0 or y<=0) return 0;
    if(x<=1 and y<=1) return 0;
    if(memo[x][y]!=0) return memo[x][y];
    int v=recur(x-2, y+1)+1;
    int b=recur(x+1, y-2)+1;
    memo[x][y]=max(v, b);
    return max(v, b);
}
int main(){
    cin>>a>>b;
    cout<<recur(a, b);
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
	int a1,a2;
	cin>>a1>>a2;
	if(a1==1&&a2==1)
	{
		cout<<0<<endl;
	}
	int cs=0;
	while(1)
	{
		if(a1<a2)
		{
			if(a1<100)
			{
				a1++;
			}
			a2-=2;
		}
		else
		{
			if(a2<100)
			{
				a2++;
			}
			a1-=2;
		}
		if(a1<=1&&a2<=1)
		{
			break;
		}
		cs++;
	}
	cout<<cs<<endl;
	getchar();
	getchar();
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long i,j,m,n,p,q,r,c,mm,d;
int main()
{
cin>>m>>n;
p=m;
q=n;

while(n>0&&m>0)
{
    mm=min(m,n);
    if(m==mm)
    {
        while(n>0)
        {
            c++;
            m+=1;
            n-=2;
            if(n==1)
                break;
        }
    }
    else
    {
        while(m>0)
        {
            c++;
            n+=1;
            m-=2;
            if(m==1)
                break;
        }

    }
}
cout<<c;
}

#include<bits/stdc++.h>
using namespace std;
int memo[110][110];
int f(int a,int b, int steps)
{
    if(memo[a][b]!=-1)
        return memo[a][b];
    if(a<=0 || b<=0)
        return steps-1;
    if(a<=2 && b<=2)
    {
        return steps+1;
    }
    memo[a][b] = max(f(a-2,b+1,steps+1),f(a+1,b-2,steps+1));
    return memo[a][b];
}
int main()
{
    memset(memo,-1,sizeof memo);
    int n,m; cin >> n >> m;
    cout << max(f(n-2,m+1,1),f(n+1,m-2,1));
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a1,a2,cd,ans;
int main()
{
	cin>>a1>>a2;
	if(a1<a2)cd=1;
	else cd=2;
	while(!(a1<=2&&a2<=2))
	{
		if(cd==1)
		{
			a1+=1;
			a2-=2;
		}
		else
		{
			a1-=2;
			a2+=1;
		}
		if(a1<a2)cd=1;
		else cd=2;
		ans++;
	}
	cout<<ans+1;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int a, b;
    int time = 0;
    cin >> a >> b;
    while(true)
    {
    	if(b >= a)
    	{

    		b -= 2;
    		a++;
    		time++;
    		if(b <= 0) break;
    		while(b > 2)
    		{
    			b -= 2;
    			a++;
    			time++;
    		}
    	}
    	else
    	{

    		a -= 2;
    		b++;
    		time++;
    		if(a <= 0) break;
    		while(a > 2)
    		{
    			a -= 2;
    			b++;
    			time++;
    		}
    	}
    }
    cout << time << endl;
	return 0;
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
     int a1,a2,t;
     cin>>a1>>a2;
     while(a1>0&&a2>0)
     {
          if(a1<a2)
          {
               a1+=1;
               a2-=2;
          }
          else
          {
               a1-=2;
               a2+=1;
          }
          t++;
     }
     cout<<t;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
    int a,b;
    int c=0;
    cin>>a>>b;
    while(a>0 && b>0)
    {
        c++;
        if(a-2>0 && b-2>0 && a<b)
            a++,b-=2;
        else if(a-2>0 && b-2>0 && b<a)
            b++,a-=2;
        else
            {
                if(a<b)
                    a++,b-=2;
                else
                    a-=2,b++;
            }
    }
    cout<<c<<endl;
    return 0;
}

#include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopb(i,a,b) for(int i=a;i>=b;i--)
#define loopm(i,a,b,step) for(int i=a;i<b;i+=step)
#define loopbm(i,a,b,step) for(int i=a;i>=b;i-=step)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define INF 1000000007
#define MOD 1000000007
#define BINF 1000000000000000001
#define int long long int
#define double long double

using namespace std;

int memo[101][101];

int f(int a,int b)
{
    if(a<=0 or b<=0)
     return 0;
    else if(memo[a][b]>0)
     return memo[a][b];
    else
    {

    memo[a][b]=max(f(a+1,b-2),f(a-2,b+1))+1;

        return memo[a][b];
    }
}

#undef int
int main()
{
#define int long long int
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a,b;
    cin>>a>>b;
    init(memo,0);
    int ans=f(a,b);
    cout<<ans;

    return 0;
}

#include <iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int counter = 0;
	while (a > 0 || b > 0)
	{
		if (a >= b)
		{
			a = a - 2;
			b++;
		}
		else
		{
			b = b - 2;
			a++;
		}

		counter++;
	}

	cout << counter;
	return 0;
}

#include<iostream>
using namespace std;

int main(){

	int a,b;
	cin>>a>>b;
	for (int i=0;;i++){
		if (a<b)
			swap(a,b);
		if (b==0||a-2<3){
			cout<<i;
			return 0;
		}
		a-=2;
		b++;
	}
	return 0;
}

/*3tlt*/
#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
	int m,n;
	while(~scanf("%d%d",&m,&n))
	{
	int t=0;
	while((m>=1) && (n>=1))
	{
		if(m>=n)
		{
			m=m-2;
			n=n+1;
		}
		else
		{
			m=m+1;
			n=n-2;
		}
		t=t+1;
	}
	printf("%d\n",t);
	//while(1)
	//	getchar();
	}
	return 0;
}

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int a1,a2;
    while(scanf("%d%d",&a1,&a2)!=EOF)
    {
        int mid=0,counter=0;
        do
        {
            if(a1==1&&a2==1)
                break;
            mid=(a1+a2)/2;
            if(a1>=mid)
            {
                a1-=2;
                a2+=1;
            }
            else
            {
                a1+=1;
                a2-=2;
            }
            counter++;
        }while(a1>0&&a2>0);
        cout<<counter<<endl;
    }
    return 0;
}

#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<list>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	int s;
	s=0;
	cin>>a>>b;
	if(a==1&&b==1)
	{
		cout<<1;
	}
	else
	{

	while(a>0&&b>0)
	{
		if(a>=b)
		{
			a-=2;
			b+=1;
			s+=1;
		}
		else
		{
			b-=2;
			a+=1;
			s+=1;
		}
	}

	cout<<s;
	}
	return 0;
}

#include <cstdio>
#include <iostream>
using namespace std;
long long  a,b,t;
int main()
{
	while(cin>>a>>b)
	{
		t=0;
		while(a>0&&b>0)
		{
			if(a<=2||b==100) a+=1,b-=2;
			else a-=2,b+=1;
			if(a>100) a=100;
			if(b>100) b=100;
		//	cout<<a<<' '<<b<<endl;
			t++;
		}
		cout<<t<<endl;
	}
}

#include <iostream>
using namespace std;

int main()
{
    int a, b, count = 0;
    cin >> a >> b;
    while(a !=0 && b != 0)
    {
        if(a>b)
        {
            b += 1;
            a -= 2;
        }
        else
        {
            a += 1;
            b -= 2;
        }
        count++;
    }
    cout << count << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
int main()
{
    ll a, b;
    cin >> a >> b;
    ll coun = 0;
    ll flag = 0;
    if (b <= 2)
    {
        flag = 1;
    }
    else
    {
        flag = 0;
    }

    while (a > 0 && b > 0)
    {
        if (flag == 0)
        {
            while (b > 2)
            {
                a++;
                b -= 2;
                coun++;
                //cout<<coun<<"@ "
                flag = 1;
            }

        }
        //cout<<a<<" "<<b<<endl;
        if (flag == 1)
        {
            while (a > 2)
            {
                b++;
                a -= 2;
                coun++;
                flag = 0;
            }

        }
        //cout<<a<<" "<<b<<endl;
        if(b<=2 && flag==0 || a<=2 && flag==1)
        {
            //cout<<"#";
            coun++;
            break;
        }

    }
    cout << coun << endl;

    return 0;
}

#include <iostream>
using namespace std;

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

int main(){
    int a,b,k;
    cin>>a>>b;
    k=f(a,b);
    cout<<k;
}

#include <iostream>
#include <queue>
using namespace std;

bool visited[1000][1000];
int main() {
    int a, b;
    cin >> a >> b;

    if( a <= 2 && b <= 2){
        cout << 0 << endl;
        return 0;
    }

    int last = 0;
    while( a > 0 && b > 0 )
    {
        if( a > b ) {
            a -= 2;
            b += 1;
        }
        else {
            a += 1;
            b -= 2;
        }

        last += 1;
    }

    cout << last << endl;
    return 0;
}

//2016-03-28 18:21:48.802000
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
using namespace std;

int main () {
	//freopen("A.in", "r", stdin);
//	freopen("out.out", "w", stdout);

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

#include <stdio.h>
#include <iostream>
#include <vector>
#include <sstream>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <cstdlib>

using namespace std;

int m[1000][1000] = { 0 };

int rec(int a, int b)
{
	if (a <= 0 || b <= 0) {
		return 0;
	}

	if (a >= 1000 || b >= 1000) {
		return 0;
	}

	if (m[a][b] > 0) {
		return m[a][b];
	}

	int aa = rec(a + 1, b - 2);
	int bb = rec(a - 2, b + 1);
	m[a][b] = ((aa > bb) ? aa : bb) + 1;
	return m[a][b];
}

int main()
{
	int a, b;

	cin >> a >> b;
	cout << rec(a, b);
}

#include<iostream>
using namespace std;

int main()
{
	int a,b,x,y,k=0;
	cin>>a>>b;
	x=(a>=b)?b:a;
	y=a+b-x;
	while((x)&&(y))
	{
		if(x>y)
		{
			x=x+y;
			y=x-y;
			x=x-y;
		}
		x++;
		y-=2;
		k++;
	}
	cout<<k;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
int maxn=0;
const int N=205;
bool f[N][N];
void find(int a,int b,int sum)
{
	if(a<2&&b<2){
		maxn=max(maxn,sum);
		return;
	}
	if(f[a][b])return ;
	f[a][b]=1;
	if(a>1)find(a-2,b+1,sum+1);
	if(b>1)find(a+1,b-2,sum+1);
}
int main()
{
	int a,b;
	cin>>a>>b;
	memset(f,0,sizeof(f));
	find(a,b,0);
	cout<<maxn<<endl;
	return 0;
}

#pragma once
#define	_CRT_SECURE_NO_DEPRECATE
//freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
//DEUX_COPY_RIGHTS_RESERVED
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <math.h>
#include <sstream>
#include <vector>
#include <sstream>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <time.h>
#include <map>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <list>
#include <time.h>
#include <limits.h>
#include <stdint.h>
#define ss stringstream
#define all(T)  T.begin() , T.end()
#define allr(T)  T.rbegin() , T.rend()
#define pii pair<int ,int >
#define ll long long
#define uint unsigned int
#define vi vector<ll>
#define ef else if
#define re  return
using namespace std;
#define rep2(n,m)  for(int i= 0 ; i<n ; i++) for(int j= 0 ; j<m ; j++)
#define repr(a,b)  for( int i =a ;i< b ;i++)
#define rep(n) for(int i= 0 ; i<n ; i++)
#define rep1(n) for (int i=1 ;i<=n ;i++)
#define repit(cont)  for ( auto it = cont.begin() ; it!= cont.end() ; it++)
#define repitr(a,b) for ( auto it = a ; it!= b ; it++)
#define TE int T; cin >> T; while (T--)
#define sz(A) A.size()
//#include "deux.h"

//ll OO = 10e6;

int n_ways = 0;

template<class _ptr  >
static
void printi(_ptr  begin, _ptr  end){

	for (auto i = begin; i != end; i++)
	{
		cout << *i;
		if (i < prev(end, 1)  )
			cout << " ";
		else
			cout << "";
	}

}

void show(vector<string > &v){

	if (v.size() > 2)
	{
		cout << "?";
		return;
	}
	for (int  i = 0; i < v.size() ; i++)
	{
		cout << v[i];
		if (i < v.size()-1)
			cout << " ";
	}
}
	map<int, vector<string> > top[10002];
	int main(){
		//freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);

		int cj = 1, j1, j2, m = 0;

		cin >> j1 >> j2;
		while (j1 > 0 && j2 > 0)
		{
			bool skip = 0;
            if (j1 == 1)
			 	cj = 1 , skip =1;
			else if (j2 == 1)
				cj = 2, skip = 1;
			else if (j1 == 1 && j2 == 1)
				break;

			if (cj == 1)
				j1++, j2 -= 2;
			else
				j2++, j1 -= 2;

				if (j1 > j2)
					cj = 2;
				else if (j2 > j1)
					cj = 1;

		m++;
	}

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

#include <iostream>
#include <fstream>

using namespace std;
int a1,a2,k;

int main()

{

    cin>>a1>>a2;
    if(a1==a2)
        cout<<a1+a2-3;
    else if(a1==1||a2==1)cout<<a1+a2-3;
    else cout<<a1+a2-2;

    return 0;
}

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n, m, s = 0;
	cin >> n >> m;
	while (n != 0 && m != 0)
	{
		if (n < m)
		{
			n += 1;
			m -= 2;
		}
		else
		{
			n -= 2;
			m += 1;
		}
			s++;
	}
	if(n==m && m==1)
    {
        cout<<0<<endl;
        return 0;
    }
	cout << s << endl;
	return 0;
}

#include<cstdio>
#include<cstring>
int dp[105][105];
int max(int a,int b){
	return a>b?a:b;
}
int DP(int a,int b){
	if(dp[a][b]!=-1)  return dp[a][b];
    if(a==0||b==0||a==1&&b==1)  return dp[a][b]=0;
    if(a==1)  return dp[a][b]=1+DP(a+1,b-2);
    else if(b==1)   return dp[a][b]=1+DP(a-2,b+1);
    dp[a][b]=max(1+DP(a+1,b-2),1+DP(a-2,b+1));
    return dp[a][b];
}
int main(){
    int a,b;
    memset(dp,-1,sizeof dp);
    scanf("%d%d",&a,&b);
	printf("%d\n",DP(a,b));
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int memo[110][110];

int f(int a,int b, int steps)
{
    if(b<a)
        swap(a,b);
    if(a<0)
        return steps-1;
    if(a==0)
        return steps;
    if(memo[a][b]!=-1)
        return memo[a][b];

    if(b<=2)
    {
        return steps+1;
    }
    memo[a][b] = f(a+1,b-2,steps+1);
    return memo[a][b];
}
int main()
{
    memset(memo,-1,sizeof memo);
    int n,m; cin >> n >> m;
    if(m<n)
        swap(n,m);
    if(n==1)
    {
        cout << 0;
        return 0;
    }

    cout << f(n+1,m-2,1);
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n, m;
	cin >> n;
	cin >> m;

	int count = 0;
	if (n != 1 && m != 1) {
		while (n > 0 && m > 0)
		{
			if (n > m)
			{
				n -= 2;
				m += 1;
			}
			else
			{
				m -= 2;
				n += 1;
			}
			count++;
		}
	}
	cout << count;

}

/*yo9q*/
#include <iostream>
#include <stdio.h>
using namespace std;

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

#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int x=a;
    int y=b;
    int counter=0;
    while(a>2||b>2){
        if(a>=b){
            a-=2;
            ++b;
            ++counter;}
        if(b>a){
            b-=2;
            ++a;
            ++counter;}
        }
        if(x==2||y==2)
            cout<<counter;
        else

        if(x==1&&y==1)
            cout<<counter;
        else
            cout<<counter+1;
return 0;}

#include<bits\stdc++.h>
using namespace std;
  int dp[1008][1008];
int main()
{
    int a,b,k,i,j;
    cin>>a>>b;
    if(a<b)
        swap(a,b);
    int ans=0;
    while(1){
    while(a-2>0)
    {
        a=a-2;
        ans++;
        b++;
    }
    while(b-2>0)
    {
        b=b-2;
        ans++;
        a++;
    }
    if(a-2<=0 && b-2<=0)
        break;
    }
    cout<<ans+1<<endl;
}

#include<bits/stdc++.h>
using namespace std;
int main ()
{int m,n,c=0;
cin>>m>>n;
if(m==1&&n==1)
cout<<1;
else
{

while(m>-1&&n>-1)
{ if(m>=n)
{ m-=2;
 n++;
}
else if(m==0||n==0)
{break;
}
else
{m++;
n-=2;
}
c++;

}
cout<<c;
}
}

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int da[102], db[102];
int solve(int a, int b){
    if(a<=0 || b<=0)
        return 0;
    if(da[a]!=-1)
        return da[a];
    if(db[b]!=-1)
        return db[b];
    return da[a] = db[b] = max(1 + solve(a-2,b+1),1 + solve(a+1,b-2));
}
int main() {
    for(int i=0;i<=101;i++){
        da[i] = db[i] = -1;
    }
    int a,b;
    cin>>a>>b;
    if(a==1 || b==1)
        cout<<1<<endl;
    else
        cout<<solve(a,b)<<endl;
    return 0;
}

#include<bits/stdc++.h>

#define NN 111111
using namespace std;
typedef long long INT;
typedef pair<int,int> pii;

int main(){
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);

	int a,b;
	cin>>a>>b;
	int k=0;
	if(a<=b){
		int t=a;a=b;b=t;
	}
	while(a>0&&b>0){
		k++;
		a-=2;b++;
		if(a<3){
			int t=a;a=b;b=t;
		}
	}
	cout<<k<<endl;
	return 0;
}