#include <bits/stdc++.h>
using namespace std;
int ans = 0, len;
string s, s1, t;
bool judge() {
  int cnt = 0, l = 0;
  while (l < s1.length()) {
    if (s1[l] == t[cnt]) cnt++;
    l++;
  }
  if (cnt == t.length()) return true;
  return false;
}
int main() {
  cin >> s >> t;
  len = s.length();
  for (int i = 1; i <= len; i++) {
    for (int j = 0; j <= len - i; j++) {
      s1.clear();
      for (int k = 0; k < len; k++) {
        if (j <= k && k < i + j)
          continue;
        else
          s1 += s[k];
      }
      if (judge()) ans = max(ans, i);
    }
  }
  cout << ans << endl;
}
