#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  long long n, m, i, j, k = 200000;
  n = a.size();
  m = b.size();
  for (i = 1; i <= k; i++) {
    if (n - i >= 0 && m - i >= 0) {
      if (a[n - i] != b[m - i]) break;
    } else
      break;
  }
  cout << (n - i) + 1 + (m - i) + 1;
}
