#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s, t;
  cin >> s >> t;
  int ns = s.size() - 1;
  int nt = t.size() - 1;
  bool stop = true;
  while (stop && (ns >= 0 && nt >= 0)) {
    if (s[ns] != t[nt]) {
      stop = false;
    }
    if (stop) {
      ns--;
      nt--;
    }
  }
  int r = ns + nt + 2;
  cout << r;
  return 0;
}
