#include <bits/stdc++.h>

using namespace std;

#define FASTIO          ios::sync_with_stdio(false);cin.tie(NULL)
#define pb              push_back
#define ub              upper_bound
#define lb              lower_bound
#define F(i, a, b)      for (int i = a; i < b; ++i)
#define R(i, a, b)      for (int i = a; i >= b; --i)

typedef long long ll;
typedef pair<int,int> pii;

int main()
{
    FASTIO;
    string a,b;
    cin >> a >> b;
    int s1=0,s2=0;
    F(i,0,3){
        s1+=a[i]-'0';
    }
    F(i,0,3){
        s2+=b[i]-'0';
    }
    cout << max(s1,s2);
    return 0;
}
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
ll divceil(ll x, ll y) { return(x % y ? x / y + 1 : x / y); }
ll invMOD(ll x) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = x / b;
    x -= t * b; 
    swap(x, b);
    u -= t * v; 
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) u += MOD;
  return u;
}
int main() {
  string A, B;
  cin >> A >> B;
  cout << max(A[0] + A[1] + A[2], B[0] + B[1] + B[2]) - '0' * 3 << "\n";
}