#include <bits/stdc++.h>
using namespace std;
int main() {
  int cnt = 1;
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < t.length(); i++) {
    static int j = 0;
    if (s[j] == t[i]) {
      cnt++;
      j++;
    } else
      continue;
  }
  cout << cnt;
  return 0;
}
