#include<bits/stdc++.h>
using namespace std;
//////////////////////////////////////////////////////////////////////////////
void files(){freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);}
void speed(){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
int lcm(int a,int b){return (a*b)/__gcd(a,b);}
int fib(int n){return (pow(1+sqrt(5),n)-pow(1-sqrt(5),n))/(pow(2,n)*sqrt(5));}
//////////////////////////////////////////////////////////////////////////////
int main()
{
    /// --- Your code here --- ///
    string a,b;cin>>a>>b;
    cout<<max((a[0]-'0')+(a[1]-'0')+(a[2]-'0'),(b[0]-'0')+(b[1]-'0')+(b[2]-'0'));
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define dd long double
#define all(x) x.begin(),x.end()

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1,s2;
    cin>>s1>>s2;
    ll a1=0,a2=0;
    REP(i,3){
        a1+=(s1[i]-'0');
        a2+=(s2[i]-'0');
    }
    cout<<max(a1,a2)<<endl;
}
