#include <bits/stdc++.h>
using namespace std;
char a[1000000];
char b[1000000];
int main() {
  scanf("%s %s", a, b);
  long int m = strlen(a);
  long int n = strlen(b);
  long int h = m + n;
  long int sum = 0;
  n--;
  for (int i = m - 1; i >= 0; i--) {
    if (a[i] == b[n])
      sum++;
    else
      break;
    n--;
  }
  long int num = h - 2 * sum;
  printf("%ld\n", num);
  return 0;
}
