#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <map>
#include <utility>
#include <vector>
#include <set>
#include <string>
#include <queue>
using namespace std;

#define ll long long int
#define INF 1000000007
#define INFLL 1000000000000000011LL
#define pb(x) push_back(x)
#define mp make_pair
#define fi first
#define se second
#define vi vector
#define gtl(x) getline(cin, (x))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define setv(x,a) memset(x,a,sizeof(x))
#define ull unsigned long long int

ull PowMod(ull n)
{
    ull ret = 1;
    ull a = 2;
    while (n > 0) {
        if (n & 1) ret = ((ret%INF) * (a%INF)) % INF;
        a = ((a%INF) * (a%INF)) % INF;
        n >>= 1;
    }
    return ret;
}

int gcd(int a, int b) {
            if (a == 0) return b;
            if (b == 0) return a;
            if (a < 0) return gcd(-1 * a, b);
            if (b < 0) return gcd(a, -1 * b);
            if (a > b) return gcd(b, a);
            return gcd(b%a, a);
}

int main() {
    string s;
    cin>>s;

    int left=0;

    int sum=0;
    int i = 0;
    int index = 0;
    while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            i++;
            index = i;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                left++;
                i++;
                index = i;
            } else i++;
        } else {
            left++;
            sum = 0;
            i++;
            index = i;
        }
    }

    if(index<s.length() && index!=0) {
        i = s.length()-1;
        while(i>=index) {
             sum = sum + (s[i]-'0');
             if((s[i]-'0')%3==0) {
                left++;
                i-- ;
                sum = 0;
                continue;
            }
            if(s[i]!='0') {
                if(sum%3==0) {
                    left++;
                    i--;
                } else i--;
            } else {
                left++;
                sum = 0;
                i--;
            }
        }
    }

    int right =0;
    sum = 0;
    i = s.length()-1;
    while(i>=0) {
        sum = sum + (s[i]-'0');
         if((s[i]-'0')%3==0) {
            right++;
            i-- ;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                right++;
                i--;
            } else i--;
        } else {
            right++;
            sum = 0;
            i--;
        }
    }

    int answer = max(left,right);
    cout<<answer<<endl;
}


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

#define mp make_pair
#define pb push_back
#define ll long long int
#define sd(x) scanf("%lld",&x)
#define inf 1e18+9
#define pll pair<ll,ll>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int MAXN = 2e5+5;

ll N;
// ll dp[MAXN][4][2];
ll dp[MAXN][4];
string S;
ll s[MAXN];

void clear() {
	for(ll i=0;i<MAXN;i++) {
		for(ll j=0;j<4;j++) {
			dp[i][j] = -1;
		}
	}
}

ll solve(ll indx, ll mod) {
	if(indx>=N) {
		return 0;
	}

	if(dp[indx][mod]!=-1) return dp[indx][mod];

	ll md = s[indx]%3;
	ll ans = 0;

	if(md==0) {
		ans = max(ans,solve(indx+1,0)+1);
	} else {
		ans = max(ans,solve(indx+1,md));
	}

	if(mod==0) {
		ll dum = s[indx]%3;
		if(dum==0) {
			ans = max(ans,solve(indx+1,0)+1);
		} else {
			ans = max(ans,solve(indx+1,dum));
		}
	} else if(mod==1 || mod==2) {
		ll dum = (mod+s[indx])%3;
		if(dum==0) {
			ans = max(ans,solve(indx+1,0)+1);
		} else {
			ans = max(ans,solve(indx+1,dum));
		}
	}

	return dp[indx][mod] = ans;
}

int main() {
	fastio;
	cin>>S;
	N = S.length();

	for(ll i=0;i<N;i++) {
		s[i] = S[i]-'0';
	}

	clear();

	ll ans = solve(0,0);
	cout<<ans<<endl;

}


#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <map>
#include <utility>
#include <vector>
#include <set>
#include <string>
#include <queue>
using namespace std;

#define ll long long int
#define INF 1000000007
#define INFLL 1000000000000000011LL
#define pb(x) push_back(x)
#define mp make_pair
#define fi first
#define se second
#define vi vector
#define gtl(x) getline(cin, (x))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define setv(x,a) memset(x,a,sizeof(x))
#define ull unsigned long long int

ull PowMod(ull n)
{
    ull ret = 1;
    ull a = 2;
    while (n > 0) {
        if (n & 1) ret = ((ret%INF) * (a%INF)) % INF;
        a = ((a%INF) * (a%INF)) % INF;
        n >>= 1;
    }
    return ret;
}

int gcd(int a, int b) {
            if (a == 0) return b;
            if (b == 0) return a;
            if (a < 0) return gcd(-1 * a, b);
            if (b < 0) return gcd(a, -1 * b);
            if (a > b) return gcd(b, a);
            return gcd(b%a, a);
}

int main() {
    string s;
    cin>>s;

    int left=0;

    int sum=0;
    int i = 0;
    int index = 0;
    /*while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            i++;
            index = i;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                left++;
                i++;
                sum = 0;
                index = i;
            } else i++;
        } else {
            left++;
            sum = 0;
            i++;
            index = i;
        }
    }*/

    int count = 0;
    while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            sum = 0;
            for(int k = i-1;k>=index;k--) {
                sum = sum + (s[k]-'0');
                if(sum%3==0) {
                    left++;
                    sum = 0;
                }
            }
            sum = 0;
            i++;
            index = i;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                sum = 0;
                count = 0;
                for(int k = i;k>=index;k--) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                if(count>1)
                    left+=count;
                else left++;
                i++;
                index = i;
            } else i++;
        } else {
                sum = 0;
                count = 0;
                for(int k = i;k>=index;k--) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                if(count>1)
                    left+=count;
                else left++;
                i++;
                index = i;
        }
    }

    if(index<s.length() && index!=0) {
        i = s.length()-1;
        while(i>=index) {
             sum = sum + (s[i]-'0');
             if((s[i]-'0')%3==0) {
                left++;
                i-- ;
                sum = 0;
                continue;
            }
            if(s[i]!='0') {
                if(sum%3==0) {
                    left++;
                    i--;
                    sum = 0;
                } else i--;
            } else {
                left++;
                sum = 0;
                i--;
            }
        }
    }

    int right =0;
    sum = 0;
    i = s.length()-1;
    while(i>=0) {
        sum = sum + (s[i]-'0');
         if((s[i]-'0')%3==0) {
            right++;
            i-- ;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                right++;
                i--;
                sum = 0;
            } else i--;
        } else {
            right++;
            sum = 0;
            i--;
        }
    }

    int answer = max(left,right);
    cout<<answer<<endl;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <map>
#include <utility>
#include <vector>
#include <set>
#include <string>
#include <queue>
using namespace std;

#define ll long long int
#define INF 1000000007
#define INFLL 1000000000000000011LL
#define pb(x) push_back(x)
#define mp make_pair
#define fi first
#define se second
#define vi vector
#define gtl(x) getline(cin, (x))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define setv(x,a) memset(x,a,sizeof(x))
#define ull unsigned long long int

ull PowMod(ull n)
{
    ull ret = 1;
    ull a = 2;
    while (n > 0) {
        if (n & 1) ret = ((ret%INF) * (a%INF)) % INF;
        a = ((a%INF) * (a%INF)) % INF;
        n >>= 1;
    }
    return ret;
}

int gcd(int a, int b) {
            if (a == 0) return b;
            if (b == 0) return a;
            if (a < 0) return gcd(-1 * a, b);
            if (b < 0) return gcd(a, -1 * b);
            if (a > b) return gcd(b, a);
            return gcd(b%a, a);
}

int main() {
    string s;
    cin>>s;

    int left=0;

    int sum=0;
    int i = 0;
    int index = 0;
    /*while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            i++;
            index = i;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                left++;
                i++;
                sum = 0;
                index = i;
            } else i++;
        } else {
            left++;
            sum = 0;
            i++;
            index = i;
        }
    }*/

    while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            sum = 0;
            for(int k = i-1;k>=index;k--) {
                sum = sum + (s[k]-'0');
                if(sum%3==0) {
                    left++;
                    sum = 0;
                }
            }
            sum = 0;
            i++;
            index = i;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                sum = 0;
                count = 0;
                for(int k = i;k>=index;k--) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                if(count>1)
                    left+=count;
                else left++;
                i++;
                index = i;
            } else i++;
        } else {
                sum = 0;
                count = 0;
                for(int k = i;k>=index;k--) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                if(count>1)
                    left+=count;
                else left++;
                i++;
                index = i;
        }
    }

    if(index<s.length() && index!=0) {
        i = s.length()-1;
        while(i>=index) {
             sum = sum + (s[i]-'0');
             if((s[i]-'0')%3==0) {
                left++;
                i-- ;
                sum = 0;
                continue;
            }
            if(s[i]!='0') {
                if(sum%3==0) {
                    left++;
                    i--;
                    sum = 0;
                } else i--;
            } else {
                left++;
                sum = 0;
                i--;
            }
        }
    }

    int right =0;
    sum = 0;
    i = s.length()-1;
    while(i>=0) {
        sum = sum + (s[i]-'0');
         if((s[i]-'0')%3==0) {
            right++;
            i-- ;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                right++;
                i--;
                sum = 0;
            } else i--;
        } else {
            right++;
            sum = 0;
            i--;
        }
    }

    int answer = max(left,right);
    cout<<answer<<endl;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <map>
#include <utility>
#include <vector>
#include <set>
#include <string>
#include <queue>
using namespace std;

#define ll long long int
#define INF 1000000007
#define INFLL 1000000000000000011LL
#define pb(x) push_back(x)
#define mp make_pair
#define fi first
#define se second
#define vi vector
#define gtl(x) getline(cin, (x))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define setv(x,a) memset(x,a,sizeof(x))
#define ull unsigned long long int

ull PowMod(ull n)
{
    ull ret = 1;
    ull a = 2;
    while (n > 0) {
        if (n & 1) ret = ((ret%INF) * (a%INF)) % INF;
        a = ((a%INF) * (a%INF)) % INF;
        n >>= 1;
    }
    return ret;
}

int gcd(int a, int b) {
            if (a == 0) return b;
            if (b == 0) return a;
            if (a < 0) return gcd(-1 * a, b);
            if (b < 0) return gcd(a, -1 * b);
            if (a > b) return gcd(b, a);
            return gcd(b%a, a);
}

int main() {
    string s;
    cin>>s;

    int left=0;

    int sum=0;
    int i = 0;
    int index = 0;
    while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            i++;
            index = i;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                left++;
                i++;
                sum = 0;
                index = i;
            } else i++;
        } else {
            left++;
            sum = 0;
            i++;
            index = i;
        }
    }

   /* while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            sum = 0;
            for(int k = i-1;k>=index;k--) {
                sum = sum + (s[k]-'0');
                if(sum%3==0) {
                    left++;
                    sum = 0;
                }
            }
            sum = 0;
            i++;
            index = i;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                sum = 0;
                count = 0;
                for(int k = i;k>=index;k--) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                if(count>1)
                    left+=count;
                else left++;
                i++;
                index = i;
            } else i++;
        } else {
                sum = 0;
                count = 0;
                for(int k = i;k>=index;k--) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                if(count>1)
                    left+=count;
                else left++;
                i++;
                index = i;
        }
    }*/

    if(index<s.length() && index!=0) {
        i = s.length()-1;
        while(i>=index) {
             sum = sum + (s[i]-'0');
             if((s[i]-'0')%3==0) {
                left++;
                i-- ;
                sum = 0;
                continue;
            }
            if(s[i]!='0') {
                if(sum%3==0) {
                    left++;
                    i--;
                    sum = 0;
                } else i--;
            } else {
                left++;
                sum = 0;
                i--;
            }
        }
    }

    int right =0;
    sum = 0;
    i = s.length()-1;
    while(i>=0) {
        sum = sum + (s[i]-'0');
         if((s[i]-'0')%3==0) {
            right++;
            i-- ;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                right++;
                i--;
                sum = 0;
            } else i--;
        } else {
            right++;
            sum = 0;
            i--;
        }
    }

    int answer = max(left,right);
    cout<<answer<<endl;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <map>
#include <utility>
#include <vector>
#include <set>
#include <string>
#include <queue>
using namespace std;

#define ll long long int
#define INF 1000000007
#define INFLL 1000000000000000011LL
#define pb(x) push_back(x)
#define mp make_pair
#define fi first
#define se second
#define vi vector
#define gtl(x) getline(cin, (x))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define setv(x,a) memset(x,a,sizeof(x))
#define ull unsigned long long int

ull PowMod(ull n)
{
    ull ret = 1;
    ull a = 2;
    while (n > 0) {
        if (n & 1) ret = ((ret%INF) * (a%INF)) % INF;
        a = ((a%INF) * (a%INF)) % INF;
        n >>= 1;
    }
    return ret;
}

int gcd(int a, int b) {
            if (a == 0) return b;
            if (b == 0) return a;
            if (a < 0) return gcd(-1 * a, b);
            if (b < 0) return gcd(a, -1 * b);
            if (a > b) return gcd(b, a);
            return gcd(b%a, a);
}

int main() {
    string s;
    cin>>s;

    int left=0;

    int sum=0;
    int i = 0;
    int index = 0;
    while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            i++;
            index = i;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                left++;
                i++;
                index = i;
            } else i++;
        } else {
            left++;
            sum = 0;
            i++;
            index = i;
        }
    }

    if(index<s.length()) {
        i = s.length()-1;
        while(i>=index) {
             sum = sum + (s[i]-'0');
             if((s[i]-'0')%3==0) {
                left++;
                i-- ;
                sum = 0;
                continue;
            }
            if(s[i]!='0') {
                if(sum%3==0) {
                    left++;
                    i--;
                } else i--;
            } else {
                left++;
                sum = 0;
                i--;
            }
        }
    }

    int right =0;
    sum = 0;
    i = s.length()-1;
    while(i>=0) {
        sum = sum + (s[i]-'0');
         if((s[i]-'0')%3==0) {
            right++;
            i-- ;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                right++;
                i--;
            } else i--;
        } else {
            right++;
            sum = 0;
            i--;
        }
    }

    int answer = max(left,right);
    cout<<answer<<endl;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <map>
#include <utility>
#include <vector>
#include <set>
#include <string>
#include <queue>
using namespace std;

#define ll long long int
#define INF 1000000007
#define INFLL 1000000000000000011LL
#define pb(x) push_back(x)
#define mp make_pair
#define fi first
#define se second
#define vi vector
#define gtl(x) getline(cin, (x))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define setv(x,a) memset(x,a,sizeof(x))
#define ull unsigned long long int

ull PowMod(ull n)
{
    ull ret = 1;
    ull a = 2;
    while (n > 0) {
        if (n & 1) ret = ((ret%INF) * (a%INF)) % INF;
        a = ((a%INF) * (a%INF)) % INF;
        n >>= 1;
    }
    return ret;
}

int gcd(int a, int b) {
            if (a == 0) return b;
            if (b == 0) return a;
            if (a < 0) return gcd(-1 * a, b);
            if (b < 0) return gcd(a, -1 * b);
            if (a > b) return gcd(b, a);
            return gcd(b%a, a);
}

int main() {
    string s;
    cin>>s;

    int left=0;

    int sum=0;
    int i = 0;
    int index = 0;
    /*while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            i++;
            index = i;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                left++;
                i++;
                sum = 0;
                index = i;
            } else i++;
        } else {
            left++;
            sum = 0;
            i++;
            index = i;
        }
    }*/

    int count = 0;
    while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            sum = 0;
            for(int k = i-1;k>=index;k--) {
                sum = sum + (s[k]-'0');
                if(sum%3==0) {
                    left++;
                    sum = 0;
                }
            }
            sum = 0;
            i++;
            index = i;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                sum = 0;
                count = 0;
                for(int k = i;k>=index;k--) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                if(count>1)
                    left+=count;
                else left++;
                i++;
                index = i;
            } else i++;
        } else {
                sum = 0;
                count = 0;
                for(int k = i;k>=index;k--) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                if(count>1)
                    left+=count;
                else left++;
                i++;
                index = i;
        }
    }

    if(index<s.length() && index!=0) {
        i = s.length()-1;
        sum = 0;
        while(i>=index) {
        sum = sum + (s[i]-'0');
            if(sum%3==0) {
                left++;
                sum=0;
                i--;
                continue;
            } else i--;
        }
    }

    int right =0;
    sum = 0;
    i = s.length()-1;
    index = i;
    count=0;
    while(i>=0) {
        sum = sum + (s[i]-'0');
         if((s[i]-'0')%3==0) {
            // right++;
            sum = 0;
            for(int k = i;k<=index;k++) {
                sum = sum + (s[k]-'0');
                if(sum%3==0) {
                    right++;
                    sum = 0;
                }
            }
            sum = 0;
            i--;
            index = i;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                sum = 0;
                count = 0;
                for(int k = i;k<=index;k++) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                if(count>1)
                    right+=count;
                else right++;
                i--;
                index = i;
            } else i--;
        } else {
            sum = 0;
            count = 0;
            for(int k = i;k<=index;k++) {
                sum = sum + (s[k]-'0');
                if(sum%3==0) {
                    count++;
                    sum = 0;
                }
            }
            if(count>1)
                right+=count;
            else right++;
            i--;
            index = i;
        }
    }

    int answer = max(left,right);
    cout<<answer<<endl;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <map>
#include <utility>
#include <vector>
#include <set>
#include <string>
#include <queue>
using namespace std;

#define ll long long int
#define INF 1000000007
#define INFLL 1000000000000000011LL
#define pb(x) push_back(x)
#define mp make_pair
#define fi first
#define se second
#define vi vector
#define gtl(x) getline(cin, (x))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define setv(x,a) memset(x,a,sizeof(x))
#define ull unsigned long long int

ull PowMod(ull n)
{
    ull ret = 1;
    ull a = 2;
    while (n > 0) {
        if (n & 1) ret = ((ret%INF) * (a%INF)) % INF;
        a = ((a%INF) * (a%INF)) % INF;
        n >>= 1;
    }
    return ret;
}

int gcd(int a, int b) {
            if (a == 0) return b;
            if (b == 0) return a;
            if (a < 0) return gcd(-1 * a, b);
            if (b < 0) return gcd(a, -1 * b);
            if (a > b) return gcd(b, a);
            return gcd(b%a, a);
}

int main() {
    string s;
    cin>>s;

    int left=0;

    int sum=0;
    int i = 0;
    int index = 0;
    /*while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            i++;
            index = i;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                left++;
                i++;
                sum = 0;
                index = i;
            } else i++;
        } else {
            left++;
            sum = 0;
            i++;
            index = i;
        }
    }*/

    int count = 0;
    while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            sum = 0;
            for(int k = i-1;k>=index;k--) {
                sum = sum + (s[k]-'0');
                if(sum%3==0) {
                    left++;
                    sum = 0;
                }
            }
            sum = 0;
            i++;
            index = i;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                sum = 0;
                count = 0;
                for(int k = i;k>=index;k--) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                if(count>1)
                    left+=count;
                else left++;
                i++;
                index = i;
            } else i++;
        } else {
                sum = 0;
                count = 0;
                for(int k = i;k>=index;k--) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                if(count>1)
                    left+=count;
                else left++;
                i++;
                index = i;
        }
    }

    if(index<s.length() && index!=0) {
        i = s.length()-1;
        sum = 0;
        while(i>=index) {
        sum = sum + (s[i]-'0');
            if(sum%3==0) {
                left++;
                sum=0;
                i--;
                continue;
            } else i--;
        }
    }

    int right =0;
    sum = 0;
    i = s.length()-1;
    while(i>=0) {
        sum = sum + (s[i]-'0');
         if((s[i]-'0')%3==0) {
            right++;
            i-- ;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                right++;
                i--;
                sum = 0;
            } else i--;
        } else {
            right++;
            sum = 0;
            i--;
        }
    }

    int answer = max(left,right);
    cout<<answer<<endl;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <map>
#include <utility>
#include <vector>
#include <set>
#include <string>
#include <queue>
using namespace std;

#define ll long long int
#define INF 1000000007
#define INFLL 1000000000000000011LL
#define pb(x) push_back(x)
#define mp make_pair
#define fi first
#define se second
#define vi vector
#define gtl(x) getline(cin, (x))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define setv(x,a) memset(x,a,sizeof(x))
#define ull unsigned long long int

ull PowMod(ull n)
{
    ull ret = 1;
    ull a = 2;
    while (n > 0) {
        if (n & 1) ret = ((ret%INF) * (a%INF)) % INF;
        a = ((a%INF) * (a%INF)) % INF;
        n >>= 1;
    }
    return ret;
}

int gcd(int a, int b) {
            if (a == 0) return b;
            if (b == 0) return a;
            if (a < 0) return gcd(-1 * a, b);
            if (b < 0) return gcd(a, -1 * b);
            if (a > b) return gcd(b, a);
            return gcd(b%a, a);
}

int main() {
    string s;
    cin>>s;

    int left=0;

    int sum=0;
    int i = 0;
    int index = 0;
    /*while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            i++;
            index = i;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                left++;
                i++;
                sum = 0;
                index = i;
            } else i++;
        } else {
            left++;
            sum = 0;
            i++;
            index = i;
        }
    }*/

    int count = 0;
    while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            sum = 0;
            for(int k = i-1;k>=index;k--) {
                sum = sum + (s[k]-'0');
                if(sum%3==0) {
                    left++;
                    sum = 0;
                }
            }
            sum = 0;
            i++;
            index = i;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                sum = 0;
                count = 0;
                for(int k = i;k>=index;k--) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                sum = 0;
                if(count>1)
                    left+=count;
                else left++;
                i++;
                index = i;
            } else i++;
        } else {
                sum = 0;
                count = 0;
                for(int k = i;k>=index;k--) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                sum = 0;
                if(count>1)
                    left+=count;
                else left++;
                i++;
                index = i;
        }
    }

    if(index<s.length() && index!=0) {
        i = s.length()-1;
        sum = 0;
        while(i>=index) {
        sum = sum + (s[i]-'0');
            if(sum%3==0) {
                left++;
                sum=0;
                i--;
                continue;
            } else i--;
        }
    }

    int right =0;
    sum = 0;
    i = s.length()-1;
    index = i;
    count=0;
    while(i>=0) {
        sum = sum + (s[i]-'0');
         if((s[i]-'0')%3==0) {
            // right++;
            sum = 0;
            for(int k = i;k<=index;k++) {
                sum = sum + (s[k]-'0');
                if(sum%3==0) {
                    right++;
                    sum = 0;
                }
            }
            sum = 0;
            i--;
            index = i;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                sum = 0;
                count = 0;
                for(int k = i;k<=index;k++) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                if(count>1)
                    right+=count;
                else right++;
                i--;
                index = i;
            } else i--;
        } else {
            sum = 0;
            count = 0;
            for(int k = i;k<=index;k++) {
                sum = sum + (s[k]-'0');
                if(sum%3==0) {
                    count++;
                    sum = 0;
                }
            }
            if(count>1)
                right+=count;
            else right++;
            i--;
            index = i;
        }
    }

    int answer = max(left,right);
    cout<<answer<<endl;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <map>
#include <utility>
#include <vector>
#include <set>
#include <string>
#include <queue>
using namespace std;

#define ll long long int
#define INF 1000000007
#define INFLL 1000000000000000011LL
#define pb(x) push_back(x)
#define mp make_pair
#define fi first
#define se second
#define vi vector
#define gtl(x) getline(cin, (x))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define setv(x,a) memset(x,a,sizeof(x))
#define ull unsigned long long int

ull PowMod(ull n)
{
    ull ret = 1;
    ull a = 2;
    while (n > 0) {
        if (n & 1) ret = ((ret%INF) * (a%INF)) % INF;
        a = ((a%INF) * (a%INF)) % INF;
        n >>= 1;
    }
    return ret;
}

int gcd(int a, int b) {
            if (a == 0) return b;
            if (b == 0) return a;
            if (a < 0) return gcd(-1 * a, b);
            if (b < 0) return gcd(a, -1 * b);
            if (a > b) return gcd(b, a);
            return gcd(b%a, a);
}

int main() {
    string s;
    cin>>s;

    int left=0;

    int sum=0;
    int i = 0;
    int index = 0;
    /*while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            i++;
            index = i;
            sum = 0;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                left++;
                i++;
                sum = 0;
                index = i;
            } else i++;
        } else {
            left++;
            sum = 0;
            i++;
            index = i;
        }
    }*/

    int count = 0;
    while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if((s[i]-'0')%3==0) {
            left++;
            sum = 0;
            for(int k = i-1;k>=index;k--) {
                sum = sum + (s[k]-'0');
                if(sum%3==0) {
                    left++;
                    sum = 0;
                }
            }
            sum = 0;
            i++;
            index = i;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                sum = 0;
                count = 0;
                for(int k = i;k>=index;k--) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                sum = 0;
                if(count>1)
                    left+=count;
                else left++;
                i++;
                index = i;
            } else i++;
        } else {
                sum = 0;
                count = 0;
                for(int k = i;k>=index;k--) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                sum = 0;
                if(count>1)
                    left+=count;
                else left++;
                i++;
                index = i;
        }
    }

    if(index<s.length() && index!=0) {
        i = s.length()-1;
        sum = 0;
        while(i>=index) {
        sum = sum + (s[i]-'0');
            if(sum%3==0) {
                left++;
                sum=0;
                i--;
                continue;
            } else i--;
        }
    }

    int right =0;
    sum = 0;
    i = s.length()-1;
    index = i;
    count=0;
    while(i>=0) {
        sum = sum + (s[i]-'0');
         if((s[i]-'0')%3==0) {
            // right++;
            sum = 0;
            for(int k = i;k<=index;k++) {
                sum = sum + (s[k]-'0');
                if(sum%3==0) {
                    right++;
                    sum = 0;
                }
            }
            sum = 0;
            i--;
            index = i;
            continue;
        }
        if(s[i]!='0') {
            if(sum%3==0) {
                sum = 0;
                count = 0;
                for(int k = i;k<=index;k++) {
                    sum = sum + (s[k]-'0');
                    if(sum%3==0) {
                        count++;
                        sum = 0;
                    }
                }
                sum=0;
                if(count>1)
                    right+=count;
                else right++;
                i--;
                index = i;
            } else i--;
        } else {
            sum = 0;
            count = 0;
            for(int k = i;k<=index;k++) {
                sum = sum + (s[k]-'0');
                if(sum%3==0) {
                    count++;
                    sum = 0;
                }
            }
            sum=0;
            if(count>1)
                right+=count;
            else right++;
            i--;
            index = i;
        }
    }

    int answer = max(left,right);
    cout<<answer<<endl;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <map>
#include <utility>
#include <vector>
#include <set>
#include <string>
#include <queue>
using namespace std;

#define ll long long int
#define INF 1000000007
#define INFLL 1000000000000000011LL
#define pb(x) push_back(x)
#define mp make_pair
#define fi first
#define se second
#define vi vector
#define gtl(x) getline(cin, (x))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define setv(x,a) memset(x,a,sizeof(x))
#define ull unsigned long long int

ull PowMod(ull n)
{
    ull ret = 1;
    ull a = 2;
    while (n > 0) {
        if (n & 1) ret = ((ret%INF) * (a%INF)) % INF;
        a = ((a%INF) * (a%INF)) % INF;
        n >>= 1;
    }
    return ret;
}

int gcd(int a, int b) {
            if (a == 0) return b;
            if (b == 0) return a;
            if (a < 0) return gcd(-1 * a, b);
            if (b < 0) return gcd(a, -1 * b);
            if (a > b) return gcd(b, a);
            return gcd(b%a, a);
}

int main() {
    string s;
    cin>>s;

    int left=0;

    int sum=0;
    int i = 0;
    while(i<s.length()) {
        sum = sum + (s[i]-'0');
        if(s[i]!='0') {
            if(sum%3==0) {
                left++;
                i++;
            } else i++;
        } else {
            left++;
            sum = 0;
            i++;
        }
    }

    int right =0;
    sum = 0;
    i = s.length()-1;
    while(i>=0) {
        sum = sum + (s[i]-'0');
        if(s[i]!='0') {
            if(sum%3==0) {
                right++;
                i--;
            } else i--;
        } else {
            right++;
            sum = 0;
            i--;
        }
    }

    int answer = max(left,right);
    cout<<answer<<endl;
}


import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	static long sx = 0, sy = 0, mod = (long) (1e9 + 7);

	static ArrayList<Integer>[] a;
	static long[][][] dp;
	static long[] fa;
	static long[] farr;
	public static PrintWriter out;
	static ArrayList<pair> pa = new ArrayList<>();
	static long[] fact = new long[(int) 1e6];
	static StringBuilder sb = new StringBuilder();
	static boolean cycle = false;
	static long m = 998244353;
	static long[] no, col;
	// static String s;
	static long k = 0, n = 0;
	static int[] c;
	static long ans = 0;
	static int[] down;
	static int[] score;

	static HashMap<Integer, ArrayList<Integer>> hm;

	public static void main(String[] args) throws IOException {

		Scanner scn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

		out = new PrintWriter(System.out);
		// Reader scn = new Reader();

		String s = scn.next(), t = scn.next();

		if (s.length() < t.length()) {
			String temp = s;
			s = t;
			t = temp;
		}

		int ele = 0;

		int i = s.length() - 1, j = t.length() - 1;

		while (j >= 0) {

			if (s.charAt(i) == t.charAt(j)) {
				ele++;
			}

			else
				break;

			i--;
			j--;
		}

		System.out.println(s.length() + t.length() - 2 * ele);
	}

	// _________________________TEMPLATE_____________________________________________________________

	// public static long lcm(long x, long y) {
	//
	// return (x * y) / gcd(x, y);
	// }
	//
	// private static long gcd(long x, long y) {
	// if (x == 0)
	// return y;
	//
	// return gcd(y % x, x);
	// }
	//
	// static class comp implements Comparator<Integer> {
	//
	// @Override
	// public int compare(Integer p1, Integer p2) {
	//
	// return p2 - p1;
	//
	// }
	// }
	//
	// }
	//
	// public static long pow(long a, long b) {
	//
	// if (b < 0)
	// return 0;
	// if (b == 0 || b == 1)
	// return (long) Math.pow(a, b);
	//
	// if (b % 2 == 0) {
	//
	// long ret = pow(a, b / 2);
	// ret = (ret % mod * ret % mod) % mod;
	// return ret;
	// }
	//
	// else {
	// return ((pow(a, b - 1) % mod) * a % mod) % mod;
	// }
	// }

	private static class pair implements Comparable<pair> {

		long val;
		long t;

		pair(long a, long b) {
			val = a;
			t = b;
		}

		@Override
		public int compareTo(pair o) {

			return (int) (this.val - o.val);
		}

		// @Override
		//
		// public int hashCode() {
		// return i;
		// }
		//
		// @Override
		//
		// public boolean equals(Object o) {
		//
		// pair p = (pair) o;
		// return this.i == p.i;
		// }

	}

	private static String reverse(String s) {

		return new StringBuilder(s).reverse().toString();
	}

	public static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[1000000 + 1]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) throws IOException {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLong();
			}
			return arr;
		}

		public int[][] nextInt2DArray(int m, int n) throws IOException {
			int[][] arr = new int[m][n];
			for (int i = 0; i < m; i++) {
				for (int j = 0; j < n; j++)
					arr[i][j] = nextInt();
			}
			return arr;
		}

		public long[][] nextInt2DArrayL(int m, int n) throws IOException {
			long[][] arr = new long[m][n];
			for (int i = 0; i < m; i++) {
				for (int j = 0; j < n; j++)
					arr[i][j] = nextInt();
			}
			return arr;
		}
		// kickstart - Solution
		// atcoder - Main
	}

}


import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

	static long sx = 0, sy = 0, mod = (long) (1e9 + 7);

	static ArrayList<Integer>[] a;
	static long[][][] dp;
	static long[] fa;
	static long[] farr;
	public static PrintWriter out;
	static ArrayList<pair> pa = new ArrayList<>();
	static long[] fact = new long[(int) 1e6];
	static StringBuilder sb = new StringBuilder();
	static boolean cycle = false;
	static long m = 998244353;
	static long[] no, col;
	// static String s;
	static long k = 0, n = 0;
	static int[] c;
	static long ans = 0;
	static int[] down;
	static int[] score;

	static HashMap<Integer, ArrayList<Integer>> hm;

	public static void main(String[] args) throws IOException {

		Scanner scn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

		out = new PrintWriter(System.out);
		// Reader scn = new Reader();

		String s = scn.next(), t = scn.next();

		int i = 0, j = 0, ans = 0;

		while (i < s.length() && j < t.length()) {

			if (s.substring(i).equals(t.substring(j)))
				break;
			else {

				if (s.length()-i > t.length()-j) {
					i++;
					ans++;
				}

				else if (t.length()-j > s.length()-i) {
					j++;
					ans++;
				}

				else {
					i++;
					j++;
					ans += 2;
				}
			}
		}

		if (i >= s.length() || j >= t.length())
			ans += s.length() - i + t.length() - j;

		System.out.println(ans);

	}

	// _________________________TEMPLATE_____________________________________________________________

	// public static long lcm(long x, long y) {
	//
	// return (x * y) / gcd(x, y);
	// }
	//
	// private static long gcd(long x, long y) {
	// if (x == 0)
	// return y;
	//
	// return gcd(y % x, x);
	// }
	//
	// static class comp implements Comparator<Integer> {
	//
	// @Override
	// public int compare(Integer p1, Integer p2) {
	//
	// return p2 - p1;
	//
	// }
	// }
	//
	// }
	//
	// public static long pow(long a, long b) {
	//
	// if (b < 0)
	// return 0;
	// if (b == 0 || b == 1)
	// return (long) Math.pow(a, b);
	//
	// if (b % 2 == 0) {
	//
	// long ret = pow(a, b / 2);
	// ret = (ret % mod * ret % mod) % mod;
	// return ret;
	// }
	//
	// else {
	// return ((pow(a, b - 1) % mod) * a % mod) % mod;
	// }
	// }

	private static class pair implements Comparable<pair> {

		long val;
		long t;

		pair(long a, long b) {
			val = a;
			t = b;
		}

		@Override
		public int compareTo(pair o) {

			return (int) (this.val - o.val);
		}

		// @Override
		//
		// public int hashCode() {
		// return i;
		// }
		//
		// @Override
		//
		// public boolean equals(Object o) {
		//
		// pair p = (pair) o;
		// return this.i == p.i;
		// }

	}

	private static String reverse(String s) {

		return new StringBuilder(s).reverse().toString();
	}

	public static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[1000000 + 1]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) throws IOException {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLong();
			}
			return arr;
		}

		public int[][] nextInt2DArray(int m, int n) throws IOException {
			int[][] arr = new int[m][n];
			for (int i = 0; i < m; i++) {
				for (int j = 0; j < n; j++)
					arr[i][j] = nextInt();
			}
			return arr;
		}

		public long[][] nextInt2DArrayL(int m, int n) throws IOException {
			long[][] arr = new long[m][n];
			for (int i = 0; i < m; i++) {
				for (int j = 0; j < n; j++)
					arr[i][j] = nextInt();
			}
			return arr;
		}
		// kickstart - Solution
		// atcoder - Main
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.Collections;
import java.util.StringTokenizer;

public class Codeforces1005B {

	public static void main(String[] args) {
		FastScanner sc=new FastScanner();
		String one = sc.next();
		String two = sc.next();
		StringBuilder sb = new StringBuilder(one);
		StringBuilder s = new StringBuilder(two);
		sb = sb.reverse();
		s = s.reverse();
		int ans = 0;
		for(int i = 0 ; i < Math.min(one.length(), two.length()) ; i++) {
			if(sb.charAt(i) == s.charAt(i)) {
				ans++;
			}else break;
		}
		if(ans == 0) {
			System.out.println(one.length() + two.length());
		}else System.out.println(one.length() + two.length() - (2 * ans));
	}

	public void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");

		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.Collections;
import java.util.StringTokenizer;

public class Codeforces1005B {

	public static void main(String[] args) {
		FastScanner sc=new FastScanner();
		String one = sc.next();
		String two = sc.next();
		StringBuilder sb = new StringBuilder(one);
		StringBuilder s = new StringBuilder(two);
		sb = sb.reverse();
		s = s.reverse();
		int ans = 0;
		for(int i = 0 ; i < Math.min(one.length(), two.length()) ; i++) {
			if(sb.charAt(i) == s.charAt(i)) {
				ans++;
			}else break;
		}
		if(ans == Math.min(one.length(), two.length())) {
			System.out.println(one.length() + two.length());
		}else System.out.println(one.length() + two.length() - (2 * ans));
	}

	public void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");

		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}

}


import java.util.*;

public class solution {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a=sc.nextLine();
		String b=sc.nextLine();
		int i=a.length()-1;
		int j=b.length()-1;
		int c=0;
		while(i>=0 && j>=0) {
			if(a.charAt(i)==b.charAt(j)) {
				i--;
				j--;
				c+=2;
			}
			else {
				break;
			}
		}
		System.out.print(a.length()+b.length()-c);
		sc.close();
	}
}


import java.util.*;

public class changlin_hw1 {

    public static void main(String[] args) {

        //  https://codeforces.com/problemset/problem/1144/B
        // {

        //     Scanner scanner = new Scanner(System.in);
        //     int n = scanner.nextInt();

        //     int[] elements = new int[n];
        //     for (int i = 0; i < elements.length; i++) {
        //         elements[i] = scanner.nextInt();
        //     }

        //     System.out.println(minElements(elements));

        // }

        //  https://codeforces.com/problemset/problem/1005/B
        {

            Scanner scanner = new Scanner(System.in);
            String s = scanner.next();
            String t = scanner.next();

            char[] sArr = new char[s.length()];
            char[] tArr = new char[t.length()];

            for (int i = 0; i < s.length(); i++) {
                sArr[i] = s.charAt(i);
            }

            for (int j = 0; j < t.length(); j++) {
                tArr[j] = t.charAt(j);
            }

            reverse(sArr);
            reverse(tArr);

            System.out.println(minMoves(sArr, tArr));

        }

    }

    // public static int minElements(int[] elements) {

    //     int oddNums = 0;
    //     int evenNums = 0;

    //     for (int i = 0; i < elements.length; i++) {
    //         if (elements[i] % 2 == 0) {
    //             evenNums++;
    //         } else {
    //             oddNums++;
    //         }
    //     }

    //     int[] odd = new int[oddNums];
    //     int[] even = new int[evenNums];

    //     int countOdd = 0;
    //     int countEven = 0;

    //     for (int j = 0; j < elements.length; j++) {
    //         if (elements[j] % 2 == 0) {
    //             even[countEven] = elements[j];
    //             countEven++;
    //         } else {
    //             odd[countOdd] = elements[j];
    //             countOdd++;
    //         }
    //     }

    //     Arrays.sort(even);
    //     Arrays.sort(odd);

    //     int min = 0;

    //     if (even.length == odd.length) {
    //         return 0;
    //     } else if (even.length - odd.length == 1 || odd.length - even.length == 1) {
    //         return 0;
    //     } else if (even.length > odd.length) {

    //         for (int k = 0; k <= ((even.length - 1) - (odd.length + 1)); k++) {
    //             min += even[k];
    //         }
    //         return min;

    //     } else if (odd.length > even.length) {

    //         for (int l = 0; l <= ((odd.length - 1) - (even.length + 1)); l++) {
    //             min += odd[l];
    //         }
    //         return min;
    //     }

    //     return -1;
    // }

    public static char[] reverse(char[] xArr)  {

        for (int i = 0; i < (xArr.length) / 2; i++) {
            char a = xArr[i];
            xArr[i] = xArr[xArr.length - 1 - i];
            xArr[xArr.length - 1 - i] = a;
        }

        return xArr;
    }

    public static int minMoves(char[] sArr, char[] tArr) {

        int min = 0;

        if (sArr[0] != tArr[0]) {
            min = sArr.length + tArr.length;
            return min;
        } else if (sArr.length <= tArr.length) {
            for (int i = 0; i < sArr.length; i++) {
                if (sArr[i] != tArr[i]) {
                    min = (sArr.length - i) + (tArr.length - i);
                } else {
                    min = tArr.length - (i + 1);
                }

            }
            return min;
        } else if (tArr.length < sArr.length) {
            for (int j = 0; j < tArr.length; j++) {
                if (tArr[j] != sArr[j]) {
                    min = (tArr.length - j) + (sArr.length - j);
                } else {
                    min = sArr.length - (j + 1);
                }

            }
            return min;
        }

        return -1;
    }

}


import java.util.*;

public class changlin_hw1 {

    public static void main(String[] args) {

        //  https://codeforces.com/problemset/problem/1144/B
        // {

        //     Scanner scanner = new Scanner(System.in);
        //     int n = scanner.nextInt();

        //     int[] elements = new int[n];
        //     for (int i = 0; i < elements.length; i++) {
        //         elements[i] = scanner.nextInt();
        //     }

        //     System.out.println(minElements(elements));

        // }

        //  https://codeforces.com/problemset/problem/1005/B
        {

            Scanner scanner = new Scanner(System.in);
            String s = scanner.next();
            String t = scanner.next();

            char[] sArr = new char[s.length()];
            char[] tArr = new char[t.length()];

            for (int i = 0; i < s.length(); i++) {
                sArr[i] = s.charAt(i);
            }

            for (int j = 0; j < t.length(); j++) {
                tArr[j] = t.charAt(j);
            }

            reverse(sArr);
            reverse(tArr);

            System.out.println(minMoves(sArr, tArr));

        }

    }

    // public static int minElements(int[] elements) {

    //     int oddNums = 0;
    //     int evenNums = 0;

    //     for (int i = 0; i < elements.length; i++) {
    //         if (elements[i] % 2 == 0) {
    //             evenNums++;
    //         } else {
    //             oddNums++;
    //         }
    //     }

    //     int[] odd = new int[oddNums];
    //     int[] even = new int[evenNums];

    //     int countOdd = 0;
    //     int countEven = 0;

    //     for (int j = 0; j < elements.length; j++) {
    //         if (elements[j] % 2 == 0) {
    //             even[countEven] = elements[j];
    //             countEven++;
    //         } else {
    //             odd[countOdd] = elements[j];
    //             countOdd++;
    //         }
    //     }

    //     Arrays.sort(even);
    //     Arrays.sort(odd);

    //     int min = 0;

    //     if (even.length == odd.length) {
    //         return 0;
    //     } else if (even.length - odd.length == 1 || odd.length - even.length == 1) {
    //         return 0;
    //     } else if (even.length > odd.length) {

    //         for (int k = 0; k <= ((even.length - 1) - (odd.length + 1)); k++) {
    //             min += even[k];
    //         }
    //         return min;

    //     } else if (odd.length > even.length) {

    //         for (int l = 0; l <= ((odd.length - 1) - (even.length + 1)); l++) {
    //             min += odd[l];
    //         }
    //         return min;
    //     }

    //     return -1;
    // }

    public static char[] reverse(char[] xArr)  {

        for (int i = 0; i < (xArr.length) / 2; i++) {
            char a = xArr[i];
            xArr[i] = xArr[xArr.length - 1 - i];
            xArr[xArr.length - 1 - i] = a;
        }

        return xArr;
    }

    public static int minMoves(char[] sArr, char[] tArr) {

        int min = 0;

        if (sArr[0] != tArr[0]) {
            min = sArr.length + tArr.length;
            return min;
        } else if (sArr.length <= tArr.length) {
            for (int i = 0; i < sArr.length; i++) {
                if (sArr[i] != tArr[i]) {
                    min = (sArr.length - i) + (tArr.length - i);
                } else if (sArr.length == 0) {
                    min = tArr.length;
                } else {
                    min = tArr.length - (i + 1);
                }

            }
            return min;
        } else if (tArr.length < sArr.length) {
            for (int j = 0; j < tArr.length; j++) {
                if (tArr[j] != sArr[j]) {
                    min = (tArr.length - j) + (sArr.length - j);
                } else if (tArr.length == 0) {
                    min = sArr.length;
                } else {
                    min = sArr.length - (j + 1);
                }

            }
            return min;
        }

        return -1;
    }

}


import java.util.*;

public class changlin_hw1 {

    public static void main(String[] args) {

        //  https://codeforces.com/problemset/problem/1144/B
        // {

        //     Scanner scanner = new Scanner(System.in);
        //     int n = scanner.nextInt();

        //     int[] elements = new int[n];
        //     for (int i = 0; i < elements.length; i++) {
        //         elements[i] = scanner.nextInt();
        //     }

        //     System.out.println(minElements(elements));

        // }

        //  https://codeforces.com/problemset/problem/1005/B
        {

            Scanner scanner = new Scanner(System.in);
            String s = scanner.next();
            String t = scanner.next();

//            char[] sArr = new char[s.length()];
//            char[] tArr = new char[t.length()];
//
//            for (int i = 0; i < s.length(); i++) {
//                sArr[i] = s.charAt(i);
//            }
//
//            for (int j = 0; j < t.length(); j++) {
//                tArr[j] = t.charAt(j);
//            }

//            reverse(sArr);
//            reverse(tArr);

            int index = 0;
            while (true) {
                int i = s.length() - index - 1;
                int j = t.length() - index - 1;
                if (i >= 0 && j >= 0 && s.charAt(i) == t.charAt(j)) {
                    index++;
                } else {
                    break;
                }
            }

            System.out.println(s.length() + t.length() - 2 * index);

        }

    }

    // public static int minElements(int[] elements) {

    //     int oddNums = 0;
    //     int evenNums = 0;

    //     for (int i = 0; i < elements.length; i++) {
    //         if (elements[i] % 2 == 0) {
    //             evenNums++;
    //         } else {
    //             oddNums++;
    //         }
    //     }

    //     int[] odd = new int[oddNums];
    //     int[] even = new int[evenNums];

    //     int countOdd = 0;
    //     int countEven = 0;

    //     for (int j = 0; j < elements.length; j++) {
    //         if (elements[j] % 2 == 0) {
    //             even[countEven] = elements[j];
    //             countEven++;
    //         } else {
    //             odd[countOdd] = elements[j];
    //             countOdd++;
    //         }
    //     }

    //     Arrays.sort(even);
    //     Arrays.sort(odd);

    //     int min = 0;

    //     if (even.length == odd.length) {
    //         return 0;
    //     } else if (even.length - odd.length == 1 || odd.length - even.length == 1) {
    //         return 0;
    //     } else if (even.length > odd.length) {

    //         for (int k = 0; k <= ((even.length - 1) - (odd.length + 1)); k++) {
    //             min += even[k];
    //         }
    //         return min;

    //     } else if (odd.length > even.length) {

    //         for (int l = 0; l <= ((odd.length - 1) - (even.length + 1)); l++) {
    //             min += odd[l];
    //         }
    //         return min;
    //     }

    //     return -1;
    // }

//    public static char[] reverse(char[] xArr)  {
//
//        for (int i = 0; i < (xArr.length) / 2; i++) {
//            char a = xArr[i];
//            xArr[i] = xArr[xArr.length - 1 - i];
//            xArr[xArr.length - 1 - i] = a;
//        }
//
//        return xArr;
//    }

//    public static int minMoves(char[] sArr, char[] tArr) {
//
//        int min = 0;
//
//        if (sArr[0] != tArr[0]) {
//            min = sArr.length + tArr.length;
//            return min;
//        } else if (sArr.length <= tArr.length) {
//            for (int i = 0; i < sArr.length; i++) {
//                if (sArr[i] != tArr[i]) {
//                    min = (sArr.length - i) + (tArr.length - i);
//                } else if (sArr.length == 0) {
//                    min = tArr.length;
//                } else {
//                    min = tArr.length - (i + 1);
//                }
//
//            }
//            return min;
//        } else if (tArr.length < sArr.length) {
//            for (int j = 0; j < tArr.length; j++) {
//                if (tArr[j] != sArr[j]) {
//                    min = (tArr.length - j) + (sArr.length - j);
//                } else if (tArr.length == 0) {
//                    min = sArr.length;
//                } else {
//                    min = sArr.length - (j + 1);
//                }
//
//            }
//            return min;
//        }
//
//        return -1;
//    }

}


import java.util.*;

public class changlin_hw1 {

    public static void main(String[] args) {

        //  https://codeforces.com/problemset/problem/1144/B
        // {

        //     Scanner scanner = new Scanner(System.in);
        //     int n = scanner.nextInt();

        //     int[] elements = new int[n];
        //     for (int i = 0; i < elements.length; i++) {
        //         elements[i] = scanner.nextInt();
        //     }

        //     System.out.println(minElements(elements));

        // }

        //  https://codeforces.com/problemset/problem/1005/B
        {

            Scanner scanner = new Scanner(System.in);
            String s = scanner.next();
            String t = scanner.next();

            int index = 0;
            while (true) {

                int i = s.length() - index - 1;
                int j = t.length() - index - 1;

                if (i >= 0 && j >= 0 && s.charAt(i) == t.charAt(j)) {
                    index++;
                } else {
                    break;
                }
            }

            System.out.println((s.length() - index) + (t.length() - index));

        }

    }

    // public static int minElements(int[] elements) {

    //     int oddNums = 0;
    //     int evenNums = 0;

    //     for (int i = 0; i < elements.length; i++) {
    //         if (elements[i] % 2 == 0) {
    //             evenNums++;
    //         } else {
    //             oddNums++;
    //         }
    //     }

    //     int[] odd = new int[oddNums];
    //     int[] even = new int[evenNums];

    //     int countOdd = 0;
    //     int countEven = 0;

    //     for (int j = 0; j < elements.length; j++) {
    //         if (elements[j] % 2 == 0) {
    //             even[countEven] = elements[j];
    //             countEven++;
    //         } else {
    //             odd[countOdd] = elements[j];
    //             countOdd++;
    //         }
    //     }

    //     Arrays.sort(even);
    //     Arrays.sort(odd);

    //     int min = 0;

    //     if (even.length == odd.length) {
    //         return 0;
    //     } else if (even.length - odd.length == 1 || odd.length - even.length == 1) {
    //         return 0;
    //     } else if (even.length > odd.length) {

    //         for (int k = 0; k <= ((even.length - 1) - (odd.length + 1)); k++) {
    //             min += even[k];
    //         }
    //         return min;

    //     } else if (odd.length > even.length) {

    //         for (int l = 0; l <= ((odd.length - 1) - (even.length + 1)); l++) {
    //             min += odd[l];
    //         }
    //         return min;
    //     }

    //     return -1;
    // }

}


//package hiougyf;
import java.util.*;

public class Main {
	public static void main (String[] args)
	 {
		Scanner sc =new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();
		int n=a.length(),m=b.length();
		int i=n-1;
		int j=m-1;
		int ans=0;
		while(i>=0&&j>=0) {
			char a1=a.charAt(i);
			char a2=b.charAt(j);
			if(a1==a2) {
				i--;
				j--;
				continue;

			}
			else {
				ans=i+j+1+1;
				break;
			}
		}
		if(i>=0&&j<0) {
			ans+=(i+1);
		}
		if(j>=0&&i<0) {
			ans+=(j+1);
			//System.out.println("g");
		}
		System.out.println(ans);
	 }

}


//package hiougyf;
import java.util.*;

public class Main {
	public static void main (String[] args)
	 {
		Scanner sc =new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();
		int n=a.length(),m=b.length();
		int i=n-1;
		int j=m-1;
		int ans=0;
		while(i>=0&&j>=0) {
			char a1=a.charAt(i);
			char a2=b.charAt(j);
			if(a1==a2) {
				i--;
				j--;
				continue;

			}
			else {
				ans=i+j+1+1;
				break;
			}
		}
		if(i==0&&j<0) {
			ans+=(i+1);
		}
		if(j==0&&i<0) {
			ans+=(j+1);
			//System.out.println("g");
		}
		System.out.println(ans);
	 }

}


import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args)throws Exception{
		Scanner in = new Scanner(System.in);
		String s = in.next();
		String str = in.next();

		int count = 0;
		int index1 = s.length() - 1;
		int index2 = str.length() - 1;

		if (str.equals(s)) {
			System.out.print(0);
		}
		else {
			while(index1 != -1 && index2 != -1 && s.charAt(index1) == str.charAt(index2)){

				count++;
				index1--;
				index2--;
			}
			if (count == 0) {
				System.out.print(str.length() + s.length());
			}

			else {
				System.out.print((str.length()-count) + (s.length()-count));
			}
		}

	}
}


import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args)throws Exception{
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		String str = in.nextLine();
		String sub = "";
		String sub1 = "";
		int ans = 0;

		if (str.equals(s)) {
			System.out.print(0);
		}
		else if (s.length() >= str.length()) {
			for (int i=0;i<str.length();i++) {
				sub = str.substring(i, str.length());
				sub1 = s.substring(s.length() - sub.length(), s.length());
				if (sub1.equals(sub)) {
					ans = (str.length() - sub.length()) + (s.length() - sub.length());
					System.out.print(ans);
					break;
				}
			}
			if (ans == 0) {
				System.out.print(str.length() + s.length());
			}
		}
		else{
			for (int i=0;i<s.length();i++) {
				sub = s.substring(i, s.length());
				sub1 = str.substring(str.length() - sub.length(), str.length());
				if (sub1.equals(sub)) {
					ans = (str.length() - sub.length()) + (s.length() - sub.length());
					System.out.print(ans);
					break;
				}

			}
			if (ans == 0) {
				System.out.print(str.length() + s.length());
			}
		}

	}
}


import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args)throws Exception{
		Scanner in = new Scanner(System.in);
		String s = in.next();
		String str = in.next();
		String sub = "";
		String sub1 = "";
		int ans = 0;

		if (s.length() >= str.length()) {
			for (int i=0;i<str.length();i++) {
				sub = str.substring(i, str.length());
				sub1 = s.substring(s.length() - sub.length(), s.length());
				if (sub1.equals(sub)) {
					ans = (str.length() - sub.length()) + (s.length() - sub.length());
					break;
				}
			}
		}
		else{
			for (int i=0;i<s.length();i++) {
				sub = s.substring(i, s.length());
				sub1 = str.substring(str.length() - sub.length(), str.length());
				if (sub1.equals(sub)) {
					ans = (str.length() - sub.length()) + (s.length() - sub.length());
					break;
				}

			}
		}

		if (ans == 0) {
			System.out.print(str.length() + s.length());
		}
		else{
			System.out.print(ans);
		}

	}
}


import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args)throws Exception{
		Scanner in = new Scanner(System.in);
		String s = in.next();
		String str = in.next();
		String sub = "";
		String sub1 = "";
		int ans = 0;

		if (str.equals(s)) {
			System.out.print(0);
		}
		else if (s.length() >= str.length()) {
			for (int i=0;i<str.length();i++) {
				sub = str.substring(i, str.length());
				sub1 = s.substring(s.length() - sub.length(), s.length());
				if (sub1.equals(sub)) {
					ans = (str.length() - sub.length()) + (s.length() - sub.length());
					System.out.print(ans);
					break;
				}
			}
			if (ans == 0) {
				System.out.print(str.length() + s.length());
			}
		}
		else{
			for (int i=0;i<s.length();i++) {
				sub = s.substring(i, s.length());
				sub1 = str.substring(str.length() - sub.length(), str.length());
				if (sub1.equals(sub)) {
					ans = (str.length() - sub.length()) + (s.length() - sub.length());
					System.out.print(ans);
					break;
				}

			}
			if (ans == 0) {
				System.out.print(str.length() + s.length());
			}
		}

	}
}


import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args)throws Exception{
		Scanner in = new Scanner(System.in);
		String s = in.next();
		String str = in.next();
		String sub = "";
		if (s.length() >= str.length()) {
			for (int i=0;i<s.length();i++) {
				sub = s.substring(i, s.length());
				if (str.contains(sub)) {
					System.out.print((str.length() - sub.length()) + (s.length() - sub.length()));
					break;
				}
			}
		}
		else {
			for (int i=0;i<str.length();i++) {
				sub = str.substring(i, str.length());
				if (s.contains(sub)) {
					System.out.print((s.length() - sub.length()) + (s.length() - sub.length()));
					break;
				}
			}
		}

	}
}


import java.io.*;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

  private static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
  private static Lib l = new Lib();

  /**
   * Delete from the Left
   * https://codeforces.com/problemset/problem/1005/B
   */
  public static void main(String[] args) {

    String s1 = l.nextLine();
    String s2 = l.nextLine();

    int s1Len = s1.length();
    int s2Len = s2.length();
    int count = 0;
    while (count != s1Len && count != s2Len) {
      if (s1.charAt(s1Len - count - 1) == s2.charAt(s2Len - count - 1)) {
        count++;
      } else {
        break;
      }
    }
    out.println(s1Len + s2Len - count * 2);

    out.close();
  }

  public static class Lib {
    BufferedReader br;
    StringTokenizer st;

    public Lib() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    private String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long[] nextLongArr(int size) {
      long[] a = new long[size];
      for (int i = 0; i < size; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

    void shuffle(long[] arr) {
      int n = arr.length;
      Random rnd = new Random();
      for (int i = 0; i < n; ++i) {
        long tmp = arr[i];
        int randomPos = i + rnd.nextInt(n - i);
        arr[i] = arr[randomPos];
        arr[randomPos] = tmp;
      }
    }

    void sort(long[] arr) {
      // mitigate quicksort's worst case
      shuffle(arr);
      Arrays.sort(arr);
    }
  }
}


import java.io.*;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

  private static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
  private static Lib l = new Lib();

  /**
   * Delete from the Left
   * https://codeforces.com/problemset/problem/1005/B
   */
  public static void main(String[] args) {

    String s1 = l.nextLine();
    String s2 = l.nextLine();

    int moves = Math.abs(s1.length() - s2.length());
    if (s1.length() > s2.length()) {
      s1 = s1.substring(moves);
    } else {
      s2 = s2.substring(moves);
    }
    int same = 0;
    for (int i = 0; i < s1.length(); i++) {
      if(s1.charAt(i) != s2.charAt(i)) {
        moves += 2 + same;
        same = 0;
      } else {
        same += 2;
      }
    }
    out.println(moves);

    out.close();
  }

  public static class Lib {
    BufferedReader br;
    StringTokenizer st;

    public Lib() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    private String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long[] nextLongArr(int size) {
      long[] a = new long[size];
      for (int i = 0; i < size; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

    void shuffle(long[] arr) {
      int n = arr.length;
      Random rnd = new Random();
      for (int i = 0; i < n; ++i) {
        long tmp = arr[i];
        int randomPos = i + rnd.nextInt(n - i);
        arr[i] = arr[randomPos];
        arr[randomPos] = tmp;
      }
    }

    void sort(long[] arr) {
      // mitigate quicksort's worst case
      shuffle(arr);
      Arrays.sort(arr);
    }
  }
}


import java.io.*;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

  private static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
  private static Lib l = new Lib();

  /**
   * Delete from the Left
   * https://codeforces.com/problemset/problem/1005/B
   */
  public static void main(String[] args) {

    String s1 = l.nextLine();
    String s2 = l.nextLine();

    int moves = Math.abs(s1.length() - s2.length());
    if (s1.length() > s2.length()) {
      s1 = s1.substring(moves);
    } else {
      s2 = s2.substring(moves);
    }
    while (!s1.equals(s2)) {
      s1 = s1.substring(1);
      s2 = s2.substring(1);
      moves += 2;
    }
    out.println(moves);

    out.close();
  }

  public static class Lib {
    BufferedReader br;
    StringTokenizer st;

    public Lib() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    private String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long[] nextLongArr(int size) {
      long[] a = new long[size];
      for (int i = 0; i < size; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

    void shuffle(long[] arr) {
      int n = arr.length;
      Random rnd = new Random();
      for (int i = 0; i < n; ++i) {
        long tmp = arr[i];
        int randomPos = i + rnd.nextInt(n - i);
        arr[i] = arr[randomPos];
        arr[randomPos] = tmp;
      }
    }

    void sort(long[] arr) {
      // mitigate quicksort's worst case
      shuffle(arr);
      Arrays.sort(arr);
    }
  }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
import java.util.StringTokenizer;

public class DeletefromLeft {
     public static void main(String[] args) {
        Scanner fs=new Scanner(System.in);
         int T=1;
         for (int tt=0; tt<T; tt++) {
             String a = new String();
             String b = new String();

             a = fs.nextLine();
             b = fs.nextLine();
            int length = Math.max(a.length(),b.length()) - Math.min(a.length(),b.length());
            if(a.isEmpty() || b.isEmpty()){
                System.out.println(length);
                return;
            }
            if(a.length() == 0 || b.length() == 0){
                System.out.println(length);
                return;
            }
            if(a.length()<b.length()){
                int j = length;
                for(int i=0;i<a.length();i++){
                    if(a.charAt(i) != b.charAt(j++) )
                        length+=2;
                }
                System.out.println(length);
                return;
            }
               if(a.length()>b.length()){
               int j = length;
                for(int i=0;i<b.length();i++){
                    if(b.charAt(i) != a.charAt(j++) )
                        length+=2;
                }
                System.out.println(length);
                return;
            }

            for(int i=0;i<a.length();i++){
                if(a.charAt(i) != b.charAt(i))
                    length+=2;
            }
            System.out.println(length);

                 }
}
}

//  static class FastScanner {
//      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
//      StringTokenizer st=new StringTokenizer("");
//      String next() {
//      while (!st.hasMoreTokens())
//          try {
//              st=new StringTokenizer(br.readLine());
//          } catch (IOException e) {
//              e.printStackTrace();
//          }
//          return st.nextToken();
//      }

//      int nextInt() {
//          return Integer.parseInt(next());
//      }
//      int[] readArray(int n) {
//          int[] a=new int[n];
//          for (int i=0; i<n; i++) a[i]=nextInt();
//          return a;
//      }
//      long nextLong() {
//          return Long.parseLong(next());
//      }
//  }

// }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
import java.util.StringTokenizer;

public class DeletefromLeft {
     public static void main(String[] args) {
        Scanner fs=new Scanner(System.in);
         int T=1;
         for (int tt=0; tt<T; tt++) {
             String a = new String();
             String b = new String();

             a = fs.nextLine();
             b = fs.nextLine();
             int i = a.length()-1;
             int j = b.length() - 1;
            int length = Math.min(a.length(),b.length());
            int count = 0;
            while(i>=0 && j>=0 ){
                if(a.charAt(i--)!=b.charAt(j--)){
                    break;
                }
                count+=2;
            }
            System.out.println(a.length()+b.length() - count);

}
     }}

//  static class FastScanner {
//      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
//      StringTokenizer st=new StringTokenizer("");
//      String next() {
//      while (!st.hasMoreTokens())
//          try {
//              st=new StringTokenizer(br.readLine());
//          } catch (IOException e) {
//              e.printStackTrace();
//          }
//          return st.nextToken();
//      }

//      int nextInt() {
//          return Integer.parseInt(next());
//      }
//      int[] readArray(int n) {
//          int[] a=new int[n];
//          for (int i=0; i<n; i++) a[i]=nextInt();
//          return a;
//      }
//      long nextLong() {
//          return Long.parseLong(next());
//      }
//  }

// }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class DeletefromLeft {
     public static void main(String[] args) {
         FastScanner fs=new FastScanner();
         int T=1;
         for (int tt=0; tt<T; tt++) {
            String a = fs.next(),b = fs.next();
            int length = Math.max(a.length(),b.length()) - Math.min(a.length(),b.length());
            if(a.length() == 0 || b.length() == 0){
                System.out.println(length);
                return;
            }
            if(a.length()<b.length()){
                int j = length;
                for(int i=0;i<a.length();i++){
                    if(a.charAt(i) != b.charAt(j++) )
                        length+=2;
                }
                System.out.println(length);
                return;
            }
               if(a.length()>b.length()){
               int j = length;
                for(int i=0;i<b.length();i++){
                    if(b.charAt(i) != a.charAt(j++) )
                        length+=2;
                }
                System.out.println(length);
                return;
            }

            for(int i=0;i<a.length();i++){
                if(a.charAt(i) != b.charAt(i))
                    length+=2;
            }
            System.out.println(length);

                 }
}

 static class FastScanner {
     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     StringTokenizer st=new StringTokenizer("");
     String next() {
     while (!st.hasMoreTokens())
         try {
             st=new StringTokenizer(br.readLine());
         } catch (IOException e) {
             e.printStackTrace();
         }
         return st.nextToken();
     }

     int nextInt() {
         return Integer.parseInt(next());
     }
     int[] readArray(int n) {
         int[] a=new int[n];
         for (int i=0; i<n; i++) a[i]=nextInt();
         return a;
     }
     long nextLong() {
         return Long.parseLong(next());
     }
 }

}


import java.util.Scanner;

public class DeleteFromLeft {
    private static Scanner in =new Scanner(System.in);

    public static void main(String[] args) {
        String s= in.next(),t=in.next();
        if(s.length()==1){
            if(t.charAt(t.length()-1)==s.charAt(0)){
                System.out.println(t.length()-s.length());
            }else{
                System.out.println(t.length()+s.length());
            }
        }else if(t.length()==1){
            if(s.charAt(s.length()-1)==t.charAt(0)){
                System.out.println(s.length()-t.length());
            }else{
                System.out.println(s.length()+t.length());
            }
        }else{
            int count =0,i=s.length()-1,j=t.length()-1;
            while (i>=0 && j>=0){
                if(s.charAt(i)==t.charAt(j)){
                    count++;
                }else{
                    break;
                }
                i--;
                j--;
            }
            if(count==0){
                System.out.println(s.length()+t.length());
            }else{
                System.out.println((s.length()-count)+(t.length()-count));
            }
        }
    }
}


import java.util.*;
import java.io.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {

    public void solve() throws Exception {

    	String a=sc.nextToken();
    	String b=sc.nextToken();
    	int l1=a.length();
    	int l2=b.length();
    	l1--;
    	l2--;
    	int count=l1+l2+2;
    	while(l1!=-1 & l2!=-1)
    	{
    		if(a.charAt(l1)!=b.charAt(l2))
    			break;
    		else
    			{
    			count-=2;
    			l1--;
    			l2--;
    			}
    	}
    	System.out.println(count);
    }

    static Throwable uncaught;

    BufferedReader in;
    FastScanner sc;
    PrintWriter out;

    @Override
    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            sc = new FastScanner(in);
            solve();
        } catch (Throwable uncaught) {
            Solution.uncaught = uncaught;
        } finally {
            out.close();
        }
    }

    public static void main(String[] args) throws Throwable {
        Thread thread = new Thread(null, new Solution(), "", (1 << 26));
        thread.start();
        thread.join();
        if (Solution.uncaught != null) {
            throw Solution.uncaught;
        }
    }

}

class FastScanner {

    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }

    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	static class FastReader
	{
	 	BufferedReader br;
	    StringTokenizer st;

	    public FastReader()
	    {
	        br = new BufferedReader(new
	                 InputStreamReader(System.in));
	    }

	    String next()
	    {
	        while (st == null || !st.hasMoreElements())
	        {
	            try
	            {
	                st = new StringTokenizer(br.readLine());
	            }
	            catch (IOException  e)
	            {
	                e.printStackTrace();
	            }
	        }
	        return st.nextToken();
	    }

	    int nextInt()
	    {
	        return Integer.parseInt(next());
	    }

	    long nextLong()
	    {
	        return Long.parseLong(next());
	    }
	    String nextLine()
	    {
	        String str = "";
	        try
	        {
	            str = br.readLine();
	        }
	        catch (IOException e)
	        {
	            e.printStackTrace();
	        }
	        return str;
	    }
	}

	public static void main(String[] args) {

		FastReader sc = new FastReader();
		String a = sc.next();
		String b = sc.next();

		//System.out.println(a + " " + b);

		System.out.println(result(a,b));

	}

	private static int result(String s, String t) {

		int w = 0;
		for(int i = s.length()-1, j= t.length()-1; i>=0 && j>=0; i--, j--) {
			if(s.charAt(i) != t.charAt(j))
				break;
			w++;
		}

		return s.length()+t.length()-2*w;

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	static class FastReader
	{
	 	BufferedReader br;
	    StringTokenizer st;

	    public FastReader()
	    {
	        br = new BufferedReader(new
	                 InputStreamReader(System.in));
	    }

	    String next()
	    {
	        while (st == null || !st.hasMoreElements())
	        {
	            try
	            {
	                st = new StringTokenizer(br.readLine());
	            }
	            catch (IOException  e)
	            {
	                e.printStackTrace();
	            }
	        }
	        return st.nextToken();
	    }

	    int nextInt()
	    {
	        return Integer.parseInt(next());
	    }

	    long nextLong()
	    {
	        return Long.parseLong(next());
	    }
	    String nextLine()
	    {
	        String str = "";
	        try
	        {
	            str = br.readLine();
	        }
	        catch (IOException e)
	        {
	            e.printStackTrace();
	        }
	        return str;
	    }
	}

	public static void main(String[] args) {

		FastReader sc = new FastReader();
		String a = sc.next();
		String b = sc.next();

		//System.out.println(a + " " + b);

		System.out.println(result(a,b));

	}

	private static int result(String a, String b) {
		int count = 0;
		int flag = 0;
		//System.out.println(count);
		while(a.length() >= 1 && b.length() >= 1) {
			//System.out.println(a);
			if(a.length() > b.length()) {
				a = a.substring(1);
				count++;
			}
			else if(a.length() < b.length()) {
				b = b.substring(1);
				count++;
			}
			else {
				if(a.equals(b)) {
					flag = 1;
					break;
				}
				else {
					a = a.substring(1);
					count++;
				}
			}
		}
		if(flag == 1)
			return count;
		return count + b.length() + a.length();
	}

}


import java.util.*;
import java.lang.*;
import java.io.*;

public class cf
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		String s1=sc.next();
		String s2=sc.next();
		int i=s1.length()-1;
		int j=s2.length()-1;
		while(i>=0 && j>=0 && s1.charAt(i)==s2.charAt(j)){
		    i--;
		    j--;

		}
		if(i<0 && j>=0){
		    System.out.println(j+1);
		}
		else if(j<0 && i>=0){
		    System.out.println(i+1);

		}
		else{
		    int su=i+j+2;
		    System.out.println(su);
		}

	}
}


import java.util.*;import java.io.*;import java.math.*;

public class Main
{

    public static void process()throws IOException
    {
        String a=nln(),b=nln();
        int len1=a.length(),len2=b.length();

        int i=len1-1,j=len2-1,res=0;

        while(i>=0 && j>=0){
            if(a.charAt(i)==b.charAt(j)){
                i--;
                j--;
            }
            else
                break;
        }

        res=i+j+2;
        pn(res);
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

        oj = System.getProperty("ONLINE_JUDGE") != null;
        if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
        int t=1;
        //t=ni();
        while(t-->0)
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;
    static long mod=(long)1e9+7l;

    static void r_sort(int arr[],int n){
        Random r = new Random();
        for (int i = n-1; i > 0; i--){
            int j = r.nextInt(i+1);

            int temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
        }
        Arrays.sort(arr);
    }

    static long mpow(long x, long n) {
        if(n == 0)
            return 1;
        if(n % 2 == 0) {
            long root = mpow(x, n / 2);
            return root * root % mod;
        }else {
            return x * mpow(x, n - 1) % mod;
        }
    }

    static long mcomb(long a, long b) {
        if(b > a - b)
            return mcomb(a, a - b);
        long m = 1;
        long d = 1;
        long i;
        for(i = 0; i < b; i++) {
            m *= (a - i);
            m %= mod;
            d *= (i + 1);
            d %= mod;
        }
        long ans = m * mpow(d, mod - 2) % mod;
        return ans;
    }
/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}