#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  long long ans = 0;
  long long l1 = a.size();
  for (long long i = 1; i < l1; i++) {
    for (long long j = 0; j <= l1 - i; j++) {
      string s = a;
      a.erase(j, i);
      long long x = 0, y = 0;
      while (x < a.size() && y < b.size()) {
        if (a[x] == b[y]) {
          y++;
        }
        x++;
      }
      if (y == b.size()) ans = max(ans, i);
      a = s;
    }
  }
  cout << ans;
}
