#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int len1 = s1.length();
  int len2 = s2.length();
  if (s1[len1 - 1] != s2[len2 - 1])
    cout << len1 + len2;
  else {
    int k = len2 - 1;
    int count = 0;
    for (int i = len1 - 1; i >= 0; i--) {
      if (s1[i] == s2[k--])
        ++count;
      else
        break;
    }
    int tot = len1 + len2 - (2 * count);
    cout << tot;
  }
  return 0;
}
