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