#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, i = 0, j = 0, k, tc;
  int n, m, len, cnt = 1;
  char s[51], t[51];
  scanf("%s", s);
  scanf("%s", t);
  len = strlen(t);
  while (t[j] != '\0') {
    if (s[i] == t[j]) i++;
    j++;
  }
  printf("%d\n", ++i);
  return 0;
}
