#include <bits/stdc++.h>
using namespace std;
int n, q;
char ch1[10000001], ch2[10000001];
int main() {
  scanf("%s%s", ch1 + 1, ch2 + 1);
  int len1 = strlen(ch1 + 1), len2 = strlen(ch2 + 1);
  int l1 = len1, l2 = len2, ans = l1 + l2, t = 0;
  while (l1 >= 1 && l2 >= 1 && ch1[l1] == ch2[l2]) l1--, l2--, t++;
  printf("%d\n", ans - t - t);
  return 0;
}
