#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[51], t[51];
  cin >> s >> t;
  short n, m, x = 0, c = 1;
  n = strlen(s);
  m = strlen(t);
  for (int i = 0; i < m; i++) {
    if (t[i] == s[x]) {
      c++;
      x++;
    }
  }
  cout << c;
}
