#include <bits/stdc++.h>   double const EPS = 3e-8;   using namespace std;   template <class T>   T gcd(T a, T b) {     return (b != 0 ? gcd<T>(b, a % b) : a);   }   template <class T>   T lcm(T a, T b) {     return (a / gcd<T>(a, b) * b);   }   struct debugger {     template <typename T>     debugger& operator,(const T& v) {       cerr << v <<   t ;       return *this;     }   } dbg;   template <class A, class B>   ostream& operator<<(ostream& o, const pair<A, B>& p) {     return o <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <class T>   ostream& operator<<(ostream& o, const vector<T>& v) {     o <<  [ ;     for (__typeof((v).end()) it = (v).begin(); it != (v).end(); ++it)       o << *it <<  ,  ;     return o <<  ] ;   }   template <class T>   ostream& operator<<(ostream& o, const set<T>& v) {     o <<  [ ;     for (__typeof((v).end()) it = (v).begin(); it != (v).end(); ++it)       o << *it <<  ,  ;     return o <<  ] ;   }   template <class T>   inline bool read(T& x) {     int c = getchar();     int sgn = 1;     while (~c && c <  0  || c >  9 ) {       if (c ==  - ) sgn = -1;       c = getchar();     }     for (x = 0; ~c &&  0  <= c && c <=  9 ; c = getchar()) x = x * 10 + c -  0 ;     x *= sgn;     return ~c;   }   int dx[] = {1, 0, -1, 0};   int dy[] = {0, 1, 0, -1};   const int NX = 1e6 + 10;   int fromFront[NX], fromBack[NX];   string a, b;   void solve(int cs) {     cin >> a >> b;     int asz = a.size();     int bsz = b.size();     int backIdx = bsz - 1;     int cur = 0;     for (int i = asz - 1; i >= 0; i--) {       if (backIdx >= 0 && a[i] == b[backIdx]) {         backIdx--;         cur++;       }       fromBack[i] = cur;     }     int frontIdx = 0;     cur = 0;     for (int i = 0; i < asz; i++) {       if (frontIdx < bsz && a[i] == b[frontIdx]) {         frontIdx++;         cur++;       }       fromFront[i] = cur;     }     int low = 0, high = 0;     int ans = 0;     while (high < asz) {       int f = 0, b = 0;       if (low > 0) f = fromFront[low - 1];       if (high + 1 < asz) b = fromBack[high + 1];       if (f + b >= bsz) {         ans = max(ans, high - low + 1);       } else {         while (f + b < bsz && low <= high) {           low++;           f = fromFront[low - 1];           if (high + 1 < asz) b = fromBack[high + 1];         }       }       high++;     }     printf( %d n , ans);   }   int main() {     int t = 1;     for (int cs = 1; cs <= t; cs++) solve(cs);     return 0;   }   