#include <bits/stdc++.h>
using namespace std;
char s[51], t[51];
int main() {
  int ans = 1, l = 0, n;
  scanf("%s%s", s, t);
  n = strlen(t);
  while (l < n) {
    if (s[ans - 1] == t[l]) ans++;
    l++;
  }
  printf("%d", ans);
  return 0;
}
