#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[55], t[55];
  cin >> s;
  cin >> t;
  long long int s1, t1, pos = 1;
  s1 = strlen(s);
  t1 = strlen(t);
  for (long long int i = 0, j = 0; i < s1 && j < t1;) {
    if (s[i] == t[j]) {
      pos++;
      i++;
      j++;
    } else
      j++;
  }
  cout << pos << endl;
  return 0;
}
