#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  string second, t;
  cin >> second >> t;
  if (second == t) {
    cout << "0";
    return 0;
  }
  int z = second.size() - 1;
  int x = t.size() - 1;
  for (int i = max(second.size(), t.size()) - 1; i >= 0; i--) {
    if (second[z] != t[x]) {
      x = t.size() - x - 1;
      z = second.size() - z - 1;
      cout << second.size() - z + t.size() - x;
      return 0;
    }
    z--;
    x--;
  }
  cout << second.size() + t.size();
  return 0;
}
