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