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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int a, b;
    cin >> a >> b;
    int s1 = 0 , s2 = 0;
    for (int i = 0; i <3; i++) {
        s1 += a%10;
        s2 += b%10;
        a /= 10;
        b /= 10;
        
    }
    cout << max(s1, s2);
}
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
const int INF = 1e9;
const int mod = 1000000007;
#define all(a) (a).begin(),(a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    string a, b;
    cin >> a >> b;
    int asum = 0, bsum = 0;
    rep(i, 3){
        asum += a[i] - '0';
        bsum += b[i] - '0';
    }
    cout << max(asum, bsum);
}