#include <bits/stdc++.h>
using namespace std;
using i16 = short;
using u16 = unsigned short;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using f32 = float;
using f64 = double;
using f80 = long double;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
constexpr int INF = 1001001001;

constexpr bool is_multiple = false;

i32 digits_sum(i32 n) {
    i32 res = 0;

    while (n > 0) {
        res += (n % 10);
        n /= 10;
    }

    return res;
}

void solve() {
    i32 a, b;
    cin >> a >> b;
    cout << max(digits_sum(a), digits_sum(b)) << endl;
}

int main() {
    i32 t = 1;
    if (is_multiple) cin >> t;
    while (t--) solve();
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main() {
    int a, b;
    cin >> a >> b;
    int sum = 0, sumi = 0; 
    rep(i,3) {
        sum += a % 10;
        a /= 10;
        sumi += b % 10;
        b /= 10;
    }
    cout << max(sum, sumi) << endl;
    return 0;
}