#include <bits/stdc++.h>
using namespace std;
string S, T;
int lS, lT;
int fir[205], las[205];
int main() {
  cin >> S >> T;
  lS = S.length(), lT = T.length();
  for (int i = 0, j = 0; i < lS && j < lT; i++)
    if (S[i] == T[j]) fir[j++] = i;
  for (int i = lS - 1, j = lT - 1; i >= 0 && j >= 0; i--)
    if (S[i] == T[j]) las[j--] = i;
  int ans = max(lS - 1 - fir[lT - 1], las[0]);
  for (int i = 1; i < lT; i++) ans = max(ans, las[i] - fir[i - 1] - 1);
  printf("%d\n", ans);
  return 0;
}
