#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  long long ls, lt, c = 0;
  cin >> s >> t;
  ls = s.length();
  lt = t.length();
  for (int i = ls - 1, j = lt - 1; i >= 0 && j >= 0; i--, j--) {
    if (t[j] != s[i])
      break;
    else
      c++;
  }
  long long ans = ls + lt - 2 * c;
  cout << ans;
}
