#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int lo = 0, hi = s.size();
  while (lo < hi) {
    int mid = (lo + hi) / 2, ind = 0, cnt = 0;
    if (hi - lo == 1) mid = hi;
    for (int i = 0; i + mid - 1 < s.size(); i++) {
      ind = 0;
      for (int j = 0; j < s.size(); j++) {
        if (j == i) j = i + mid;
        if (j >= s.size()) break;
        if (s[j] == t[ind]) ind += 1;
      }
      if (ind == t.size()) cnt += 1;
    }
    if (cnt > 0)
      lo = mid;
    else
      hi = mid - 1;
  }
  cout << lo;
  return 0;
}
