/***
    Description: Simulation

   * author:    Diego Briaares
   * date:   24.01.2021 18:11:37
***/

#include <bits/stdc++.h>
using namespace std;
	int main () {
		ios_base::sync_with_stdio(0);
		cin.tie(0);
		string a, b;
		cin >> a >> b;
		int sa = 0, sb = 0;
		for (int i = 0; i < a.size(); i++) {
			sa += a[i] - '0';
			sb += b[i] - '0';
		}
		cout << max(sa, sb) << "\n";
	}
#include <bits/stdc++.h>

using namespace std;

int main()
{

  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  // to read the input from file
  // freopen("cpp_input.txt", "r", stdin);
  int num1, num2, rem1, rem2, sum1 = 0, sum2 = 0;
  cin >> num1 >> num2;
  while (num1 > 0 and num2 > 0)
  {
    rem1 = num1 % 10;
    sum1 += rem1;
    num1 /= 10;
    rem2 = num2 % 10;
    sum2 += rem2;
    num2 /= 10;
  }
  if (sum1 > sum2)
    cout << sum1;
  else
    cout << sum2;
}