#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3F3F3F3F;
const long long INF_LL = 0x3F3F3F3F3F3F3F3FLL;
const int N = 4e5 + 50;
bool check(const string &s, const string &t) {
  int match = 0;
  for (int i = 0; i < s.size() && match < t.size(); ++i) {
    if (s[i] == t[match]) ++match;
  }
  return match == t.size();
}
int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < int(s.size()); ++i) {
    for (int j = i; j < int(s.size()); ++j) {
      string tmp = s;
      tmp.erase(tmp.begin() + i, tmp.begin() + j + 1);
      if (check(tmp, t)) ans = max(ans, j - i + 1);
    }
  }
  cout << ans << endl;
  return 0;
}
