#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
char a[maxn], b[maxn];
int la, lb, ans;
int main() {
  scanf("%s%s", a, b);
  la = strlen(a);
  lb = strlen(b);
  ans = -1;
  for (int i = 0; i < min(la, lb); i++)
    if (a[la - i - 1] != b[lb - i - 1]) {
      ans = la - i + lb - i;
      break;
    }
  if (ans == -1) ans = max(la, lb) - min(la, lb);
  printf("%d\n", ans);
  return 0;
}
