#include <bits/stdc++.h>
#define endl '\n'
#define modulo 1000000007
#define int long long
#define PI acos(-1)
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")
#define sinDegrees(x) sin((x) * PI / 180.0)
#define cosDegrees(x) cos((x) * PI / 180.0)
#define tanDegrees(x) tan((x) * PI / 180.0)
#define atanDegrees(x) atan(x)* 180.0 / PI
#define asinDegrees(x) asin(x)* 180.0 / PI
#define EPS 0.000000001
using namespace std;
int power(int x,int y,int m)
{
int temp;
if(y == 0)
return 1;
temp = (power(x, y/2,m))%m;
if (y%2 == 0)
return ((temp%m)*temp);
else
return ((x*temp%m)*temp%m)%m;
}
int inv(int x,int m=modulo)
{
return (power(x,m-2,m))%m;
}
///IOI 2021 isA
int32_t main()
{
//freopen("output.txt","w",stdout);
//freopen("colors.in","r",stdin);
cin.tie(0),iostream::sync_with_stdio(0);
string a,b;
cin>>a>>b;
int S=0,S2=0;
for(int i=0;i<a.size();i++)
S+=a[i]-'0',S2+=b[i]-'0';
cout<<max(S,S2);
return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<long long, long long> pl;

#define rep(i, a, b) for (int i = a; i < b; i++)


void solve()
{
    ll a, b;
    cin >>a >> b;

    ll sa = 0;
    while(a > 0){
        sa += a%10;
        a/=10;
    }

    ll sb = 0;
    while(b > 0){
        sb += b%10;
        b/=10;
    }

    cout << max(sa, sb) << endl;
}

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(0); 
    cin.tie(0);
    // int t;
    // cin >> t;
    // while(t--)
        solve();
    return 0;
}
