#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e+9 + 9;
const long double EPS = 1e-9;
const long double PI = 3.1415926535897932384626433832795;
const int MAXN = 100;
int ans;
char s[MAXN], t[MAXN];
int main() {
  gets(s);
  gets(t);
  int len = strlen(t);
  for (int i = 0; i < len; ++i)
    if (s[ans] == t[i]) ++ans;
  printf("%d", ans + 1);
  return 0;
}
