#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll INF = 1LL << 60;

int main(){
    string a, b;
    cin >> a >> b;
    int ai, bi;
    ai = (a[0] - '0') + (a[1] - '0') + (a[2] - '0');
    bi = (b[0] - '0') + (b[1] - '0') + (b[2] - '0');

    if(ai >= bi) cout << ai << endl;
    else cout << bi << endl;

}

#include <bits/stdc++.h>

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000
#define MOD 1000000007

int digsum(int n) {
    int ans = 0;
    while (n) {
        ans += n % 10;
        n /= 10;
    }
    return ans;
}

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