#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,s,n) for(int i = s; i < (int)(n); i++)

int main() {
	string a, b;
	cin >> a >> b;
	int aa = 0, bb = 0;
	rep(i, 0, 3) {
		aa += a[i] - '0';
		bb += b[i] - '0';
	}
	cout << max(aa, bb) << endl;
}
#include <bits/stdc++.h>
using namespace std;

int main()
{
  string a, b;
  cin >> a >> b;
  
  int sa = 0, sb = 0;
  for (int i = 0; i < 3; i++) {
    sa += a.at(i) - '0';
    sb += b.at(i) - '0';
  }
  
  if (sa > sb) {
    cout << sa << endl;
  } else {
    cout << sb << endl;
  }
}