#include <bits/stdc++.h>
using namespace std;
int main() {
  int T1 = 0, S1 = 0, k = 0, pasx = 1;
  string S;
  cin >> S;
  string T;
  cin >> T;
  S1 = S.size();
  T1 = T.size();
  for (int i = 0; i < T1; i++) {
    if (S[k] == T[i]) {
      pasx++;
      k++;
    }
  }
  cout << pasx;
  return 0;
}
