#include <bits/stdc++.h>
using namespace std;
char s1[205], s2[205];
int ans, x, y, s[205], e[205];
int main() {
  scanf("%s", s1 + 1);
  scanf("%s", s2 + 1);
  int len1 = strlen(s1 + 1), len2 = strlen(s2 + 1);
  x = 0;
  y = len1 + 1;
  for (int i = 1; i <= len2; i++) {
    for (int j = x + 1; j <= len1; j++) {
      if (s1[j] == s2[i]) {
        x = s[i] = j;
        break;
      }
    }
  }
  for (int i = len2; i >= 1; i--) {
    for (int j = y - 1; j >= 1; j--) {
      if (s1[j] == s2[i]) {
        y = e[i] = j;
        break;
      }
    }
  }
  ans = max(len1 - s[len2], e[1] - 1);
  for (int i = 1; i < len2; i++) ans = max(ans, e[i + 1] - s[i] - 1);
  cout << ans;
  return 0;
}
