#include <bits/stdc++.h>
using namespace std;
double tick() {
  static clock_t oldt;
  clock_t newt = clock();
  double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;
  oldt = newt;
  return diff;
}
template <typename T>
T gcd(T a, T b) {
  return (b ? __gcd(a, b) : a);
}
template <typename T>
T lcm(T a, T b) {
  return (a * (b / gcd(a, b)));
}
template <class T>
inline T square(T value) {
  return value * value;
}
double intlog(double base, double x) {
  return (double)((double)log(x) / (double)log(base));
}
const int MAX = 1e5 + 5;
const int LIM = 100e5 + 5;
const int MOD = 1e9 + 7;
const long double EPS = 1e-10;
const long long LLINF = 5011501150111LL;
const double PI = acos(-1.0);
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long int power(long long int a, long long int p, long long int mod) {
  long long int result = 1;
  if (p == 0) return 1;
  if (p == 1) return a;
  while (p) {
    if (p & 1) result *= a;
    result %= mod;
    p >>= 1;
    a *= a;
    a %= mod;
  }
  return result;
}
vector<vector<int>> allSubsequenceList;
void getAllSubsequences(vector<int> arr, int n) {
  vector<int> currentSubsequenceList;
  unsigned int opsize = pow(2, n);
  for (int counter = 1; counter < opsize; counter++) {
    currentSubsequenceList.clear();
    for (int j = 0; j < n; j++) {
      if (counter & (1 << j)) {
        currentSubsequenceList.push_back(arr[j]);
      }
    }
    allSubsequenceList.push_back(currentSubsequenceList);
  }
}
vector<pair<long long, long long>> get_fact(long long x) {
  vector<pair<long long, long long>> ret;
  for (long long i = 2; i * i <= x; i++) {
    if (x % i) continue;
    int cnt = 0;
    while (x % i == 0) {
      x /= i;
      cnt++;
    }
    ret.push_back(make_pair(i, cnt));
  }
  if (x > 1) ret.push_back(make_pair(x, 1));
  return ret;
}
vector<long long> s;
void primeFactors(long long n) {
  while (n % 2 == 0) {
    s.push_back(2);
    n = n / 2;
  }
  for (long long i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      s.push_back(i);
      n = n / i;
    }
  }
  if (n > 2) s.push_back(n);
}
vector<long long> printDivisors(long long n) {
  vector<long long> v;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        v.push_back(i);
      else {
        v.push_back(n / i);
        v.push_back(i);
      }
    }
  }
  return v;
}
bool visited[1005];
vector<int> adj[1005];
map<int, int> noOfLeafChilds;
void dfs(int node) {
  if (!visited[node]) {
    visited[node] = true;
    for (int i : adj[node]) {
      dfs(i);
    }
  }
}
long long countDivisors(long long n) {
  long long cnt = 0;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        cnt++;
      else
        cnt = cnt + 2;
    }
  }
  return cnt;
}
long long gcd(long long a, long long b) {
  if (!a) return b;
  return gcd(b % a, a);
}
bool isSubSequence(string str1, string str2, int m, int n) {
  int j = 0;
  for (int i = 0; i < n && j < m; i++)
    if (str1[j] == str2[i]) j++;
  return (j == m);
}
int main() {
  string a;
  string b;
  cin >> a >> b;
  int ans = 0;
  for (int i = 0; i < a.length(); i++) {
    for (int j = i; j < a.length(); j++) {
      string c;
      for (int k = 0; k < i; k++) c += a[k];
      for (int k = j + 1; k < a.length(); k++) c += a[k];
      if (isSubSequence(b, c, b.length(), c.length())) {
        ans = max(ans, j - i + 1);
      }
    }
  }
  cout << ans << endl;
}
