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