#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s;
  cin >> t;
  int slen = s.size();
  int tlen = t.size();
  int i = slen - 1;
  int j = tlen - 1;
  int ctr = 0;
  while (i >= 0 && j >= 0) {
    if (s[i] == t[j]) {
      i--;
      j--;
    } else
      break;
  }
  int moves = i + j + 2;
  cout << moves << "\n";
  return 0;
}
