#include <bits/stdc++.h>
using namespace std;
bool f(const string& s, const string& t, int length, int n, int m) {
  if (n - length < m) return false;
  for (int pos = 0; pos + length <= n; ++pos) {
    int i = 0, j = 0;
    while (i < m && j < n) {
      if (j == pos) {
        j += length;
      }
      if (t[i] == s[j]) {
        ++i;
        ++j;
      } else {
        ++j;
      }
    }
    if (i == m) return true;
  }
  return false;
}
int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  int left = 0, right = n;
  while (left != right - 1) {
    int mid = (left + right) / 2;
    if (f(s, t, mid, n, m)) {
      left = mid;
    } else {
      right = mid;
    }
  }
  cout << left << "\n";
  return 0;
}
