#include<bits/stdc++.h>
using namespace std;
int Large_digit(int a,int b){
    int sum1=0,sum2=0;
   while(a!=0){
    int r=a%10;
    sum1+=r;
    a/=10;
   }
   while(b!=0){
    int p=b%10;
    sum2+=p;
    b/=10;
   }
   return max(sum1,sum2);
}
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<Large_digit(a,b)<<endl;
}

#include<bits/stdc++.h>
#include <iostream> 
using namespace std;
typedef  long long int ll;
#include<string.h>
#define pi 3.1415926535897932384626433832795028841971
#define fastttt ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
#define str_max_len 4294967295
#define mod 1000000007
#define max_ll LLONG_MAX
#define min_ll LLONG_MIN
#define cps CLOCKS_PER_SEC
#define pb push_back
#define fi first
#define se second
#define in insert
#define m_p make_pair
#define p_q priority_queue
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define vii vector <pair<ll,ll>> 
#define pii pair<ll,ll>
#define vi vector <ll>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
 
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
 
ll fact[250005],fact_inv[250005];
 
 
ll power(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans; 
}
 
void pre(){
    fact[0]=1;
    fact_inv[0]=1;
    for(int i=1;i<250005;i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
        fact_inv[i]=power(fact[i],mod-2);
    }
}
ll ncr(ll n,ll r){
    if(n<r){return 0;}
    if(n==r||r==0){return 1;}
    return (((fact[n]*fact_inv[n-r])%mod)*fact_inv[r])%mod;
    //return x; 
}
ll mod_inverse(ll x){
    return power(x,mod-2);
}
 
bool sortbysec(const pair<ll,ll> &a, 
              const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
}  
 
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
#define nx 100005
 
//before dp think greedy   
/***************************code begins here*****************************/
 
 
class solver{
	public:
	
	ll f(ll x)
	{
		ll s=0;
		while(x!=0)
		{
			s+=x%10;
			x=x/10;
		}
		return s;
	}
		
	void solve()
	{
		ll a,b;cin>>a>>b;
		cout<<max(f(a),f(b));
	}
};
 
int main(){
	fastttt
	//	cout<<fixed<<setprecision(10);
	
	int test=1,c=1;
	//pre();
	//cin>>test;
	while(test--){
		//cout<<"Case #"<<c<<": ";c++;
		solver o;
		o.solve();
	}
}