#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 3;
const int INF = 1e9 + 7;
string a, b, cur;
int main() {
  cin >> a >> b;
  if (a.back() != b.back()) {
    cout << (a.size() + b.size());
    return 0;
  }
  int j = a.size() - 1, cur = 0;
  for (int i = b.size() - 1; i >= 0; --i) {
    if (b[i] == a[j]) {
      cur++;
    } else {
      break;
    }
    if (j == 0) {
      break;
    }
    j--;
  }
  cout << (a.size() + b.size()) - (cur * 2);
  return 0;
}
