#include <bits/stdc++.h>
using namespace std;
long long int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
void solve() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int l = 0; l < s.length(); l++) {
    for (int r = l; r < s.length(); r++) {
      string str;
      int mx1 = 0, mx2 = 0, temp = 0, ptr = 0;
      for (int i = 0; i < l; i++) str.push_back(s[i]);
      for (int i = r + 1; i < s.length(); i++) str.push_back(s[i]);
      for (int i = 0; i < str.length(); i++) {
        if (ptr < t.length() && str[i] == t[ptr]) {
          mx1 = max(mx1, temp);
          temp = 0;
          ptr++;
        } else
          temp++;
      }
      if (ptr == t.length()) {
        ans = max(ans, r - l + 1);
      }
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  ;
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
