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

#define FREP(i,a,b) for(long long i=a;i<b;i++)
#define REP(i,n) FREP(i,0,n)
#define PB push_back
#define ll long long
#define MP make_pair
#define mod 1000000007
#define endl "\n"
#define vi vector<ll>
#define si set<ll>
#define mi map<ll,ll>
#define bs binary_search
#define pri(a,n) REP(i,n)cout<<a[i]<<" ";
#define all(x) x.begin(),x.end()
#define sz(a) (ll)a.size()
#define sa(a,n) sort(a,a+n)
#define sra(a,n) sort(a,a+n,greater<ll>())
#define sv(v) sort(all(v))
#define srv(v) sort(v.rbegin(),v.rend())
#define sp(x) fixed<<setprecision(x)
#define mem(a) memset(a,-1,sizeof(a))
#define ff first
#define ss second
#define deb(x) cout<<#x<<' '<<x<<endl;
#define FASTIO ios_base::sync_with_stdio(false);\
               cin.tie(NULL);\
               cout.tie(NULL);

void _a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z()
{
    ll n, k, q = 0, c = 0;
    string s;
    cin >> n >> k;
    while (n) {
        c += (n % 10);
        n /= 10;
    }
    while (k) {
        q += (k % 10);
        k /= 10;
    }
    cout << max(c, q);
}

int main()
{
    FASTIO;
    int t = 1;
    // cin >> t;         // Test Case :-||-: //

    while (t--)
    {
        _a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z();
    }

    return 0;
}

// Thanks for stalking :P
#include<iostream>
using namespace std;
#include<vector>
#include <algorithm>
#define re(i,n) for(int i = 0; i < n; i++)
const int MOD = 998244353;

long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}


int main() {
    string sa, sb;
    cin >> sa >> sb;

    int a = ctoi(sa[0]) + ctoi(sa[1]) + ctoi(sa[2]);
    int b = ctoi(sb[0]) + ctoi(sb[1]) + ctoi(sb[2]);

    if(a > b) cout << a << endl;
    else cout << b << endl;

    return 0;

}
