#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long L1, L2, L, d, i, j, k, sum = 0;
  string a, b;
  cin >> a >> b;
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  L1 = a.size();
  L2 = b.size();
  L = min(L1, L2);
  for (i = 0; i < L; i++) {
    if (a[i] == b[i])
      sum++;
    else
      break;
  }
  cout << setprecision(30) << L1 + L2 - 2 * sum;
  return 0;
}
