#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, s1;
  cin >> s >> s1;
  int a = s.size();
  int b = s1.size();
  int i = 1, ln = min(a, b);
  for (i = 1; i <= ln; i++) {
    if (s[a - 1] != s1[b - 1]) {
      break;
    }
    --a, --b;
  }
  cout << a + b << endl;
}
