#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    int sum=0;
    int sum2=0;
    for(int i=0;i<a.size();i++){
        sum=sum+(a[i]-'0');
    }
    for(int i=0;i<b.size();i++){
        sum2=sum2+(b[i]-'0');
    }
    if(sum>sum2) cout<<sum<<endl;
    else if(sum2>sum) cout<<sum2<<endl;
    else cout<<sum<<endl;
    return 0;
}

#pragma GCC optimize("Ofast")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

int sum(int n){
    int s=0;
    while(n>0){
        s+=n%10;
        n/=10;
    }
    return s;
}
void solve() {
    int a,b; cin>>a>>b;
    cout<<max(sum(a),sum(b));
}

int32_t main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}