#include <bits/stdc++.h>
using namespace std;
bool check(string s1, string s2) {
  int bor = 0;
  for (int i = 0; i < s1.size(); ++i) {
    if (s1[i] == s2[bor]) bor++;
    if (bor == s2.size()) break;
  }
  return bor == s2.size();
}
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int n = s1.size();
  int ans_left = -1, ans_right = -1;
  for (int left = 0; left < n; ++left) {
    for (int right = left; right < n; ++right) {
      string str = s1.substr(0, left) + s1.substr(right + 1, n - right - 1);
      if (check(str, s2) &&
          (right - left + 1 > ans_right - ans_left + 1 || ans_left == -1)) {
        ans_left = left;
        ans_right = right;
      }
    }
  }
  cout << (ans_left == -1 ? 0 : ans_right - ans_left + 1);
}
