#include <bits/stdc++.h>
using namespace std;
string a, b;
int main() {
  cin >> a >> b;
  int l1 = a.size();
  int l2 = b.size();
  int maxx = 0;
  for (int i = 0; i < l1; ++i) {
    for (int j = i; j < l1; ++j) {
      int p = 0;
      for (int k = 0; k < i; ++k) {
        if (p < l2) {
          if (a[k] == b[p]) {
            p++;
          }
        }
      }
      for (int k = j + 1; k < l1; ++k) {
        if (p < l2) {
          if (a[k] == b[p]) {
            p++;
          }
        }
      }
      if (p == l2) {
        maxx = max(maxx, j - i + 1);
      }
    }
  }
  cout << maxx;
  return 0;
}
