#include <bits/stdc++.h>
using namespace std;
int ans;
int main() {
  string s;
  string s1;
  cin >> s >> s1;
  int m = s.size();
  int n = s1.size();
  for (int i = m - 1, j = n - 1; i >= 0 && j >= 0; i--, j--) {
    if (s[i] == s1[j])
      ans++;
    else
      break;
  }
  long long j = m + n - 2 * ans;
  cout << j;
  return 0;
}
