#include <bits/stdc++.h>
using namespace std;
map<char, int> posL;
string al = "abcdefghijklmnopqrstuvwxyz";
int main() {
  string a, b;
  cin >> a >> b;
  int lenA = a.length() - 1, lenB = b.length() - 1;
  int res = lenA + lenB + 2;
  while (true) {
    if (a[lenA] == b[lenB]) {
      lenA--;
      lenB--;
      res -= 2;
    } else
      break;
    if (lenA < 0 || lenB < 0) break;
  }
  cout << res;
}
