#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s1, s2;
  cin >> s1 >> s2;
  int c = 0;
  int i = s2.size() - 1;
  int j = s1.size() - 1;
  while (i != -1 && j != -1) {
    if (s1[j] != s2[i]) {
      break;
    } else {
      c += 2;
    }
    i--;
    j--;
  }
  cout << (s1.size() + s2.size()) - c;
  return 0;
}
