#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  if (s2.size() > s1.size()) swap(s1, s2);
  int x = s1.size() - s2.size();
  for (int i = 0; i < s1.size() && i < s2.size(); ++i) {
    if (s1[s1.size() - i - 1] != s2[s2.size() - i - 1]) {
      x = s1.size() - i + s2.size() - i;
      break;
    }
  }
  cout << x << endl;
  return 0;
}
