#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, r;
  cin >> s >> r;
  int n = s.length(), m = r.length();
  int i = n - 1, j = m - 1;
  while (i >= 0 && j >= 0 && s[i] == r[j]) {
    i--;
    j--;
  }
  int ans = i + j + 2;
  cout << ans << endl;
  return 0;
}
