#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
int calc(int x){
	int ret=0;
	while (x){
		ret+=x%10;
		x/=10;
	}
	return ret;
}
int main(){
	int a=read(),b=read();
	cout<<max(calc(a),calc(b))<<'\n';
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/

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

int fanc(string S){
    int ret=0;
    ret += S[0]-'0';
    ret += S[1]-'0';
    ret += S[2]-'0';
    return ret;
}

int main() {
    string A,B;
    cin>>A>>B;
    
    int ans = max(fanc(A),fanc(B));
    
    cout<<ans<<endl;
    return 0;
    //解説を見た
}
