#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int a = s.length();
  int b = t.length();
  int mi;
  if (a < b)
    mi = a;
  else
    mi = b;
  a--;
  b--;
  int p = 0;
  int q = 0;
  for (int i = 0; i < mi; i++) {
    if (s[a] != t[b]) break;
    if ((a == 0) && (b == 0)) {
      q = 1;
      break;
    }
    if ((a == 0) || (b == 0)) {
      p = 1;
      break;
    }
    a--;
    b--;
  }
  if (p == 1)
    cout << a + b;
  else if (q == 1)
    cout << 0;
  else
    cout << a + b + 2;
  return 0;
}
