#include <bits/stdc++.h>
int main() {
  char s[1000], t[1000];
  int slen, tlen, counter = 0;
  scanf("%s", &s);
  scanf("%s", &t);
  slen = strlen(s);
  tlen = strlen(t);
  for (int j = 0; j < tlen; j++) {
    if (t[j] == s[counter]) counter++;
  }
  printf("%d", counter + 1);
}
