#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  string s, t;
  cin >> s >> t;
  int i = 0, j = 0, n, m;
  n = s.length();
  m = t.length();
  while (j < m) {
    if (s[i] == t[j]) i++;
    j++;
  }
  cout << i + 1;
  return 0;
}
