#include <bits/stdc++.h>
using namespace std;
clock_t T;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  ;
  string s, z;
  cin >> s >> z;
  if (s.back() != z.back()) return cout << (int)s.size() + (int)z.size(), 0;
  int idx1 = (int)s.size() - 1, idx2 = (int)z.size() - 1, x = 0;
  while (idx1 >= 0 && idx2 >= 0) {
    if (s[idx1] == z[idx2])
      x += 2;
    else
      break;
    idx1--, idx2--;
  }
  cout << ((int)s.size() + (int)z.size()) - x;
}
