#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const int size = 3005;
int main() {
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  if (s.size() < t.size()) swap(s, t);
  int dif = s.size() - t.size();
  for (int i = s.size() - 1; i >= 0; i--)
    if (s[i] != t[i - dif]) {
      cout << i + 1 + i + 1 - dif;
      return 0;
    }
  int a = s.size();
  int b = t.size();
  cout << a - b;
  return 0;
}
