#include <bits/stdc++.h>
using namespace std;
long long n, m;
string s, d;
int main() {
  cin >> s >> d;
  if (s == d) {
    cout << 0;
    return 0;
  }
  n = s.size();
  m = d.size();
  while (s[n] == d[m]) {
    n--;
    m--;
  }
  cout << n + m + 2;
}
