#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.length(); ++i) {
    for (int j = i; j < s.length(); ++j) {
      int pos = 0;
      for (int p = 0; p < s.length(); ++p) {
        if (i <= p && p <= j) continue;
        if (pos < t.length() && t[pos] == s[p]) ++pos;
      }
      if (pos == t.length()) ans = max(ans, j - i + 1);
    }
  }
  cout << ans << endl;
  return 0;
}
