#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  int l, r, ans;
  cin >> a >> b;
  l = (int)a.size();
  r = (int)b.size();
  l--;
  r--;
  while (a[l] == b[r]) {
    l--;
    r--;
    if (l < 0 || r < 0) break;
  }
  ans = l + 1 + r + 1;
  cout << ans << endl;
}
