#include <bits/stdc++.h>
int main() {
  char s[50], t[50];
  int pos = 0, i, j = 0, lens, lent;
  scanf("%s %s", s, t);
  lens = strlen(s);
  lent = strlen(t);
  for (i = 0; i < lent; i++) {
    if (s[pos] == t[i]) pos++;
  }
  printf("%d", pos + 1);
  printf("\n");
  return 0;
}
