#include <bits/stdc++.h>   using namespace std;   const long long int m = pow(10, 9) + 7;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string s, t;     cin >> s >> t;     int j = 0, l = -1, r = -1;     for (int i = 0; i < t.length(); i++) {       if (s[j] == t[i]) j++;       if (j == s.length()) {         l = i + 1;         break;       }     }     reverse(s.begin(), s.end());     j = 0;     reverse(t.begin(), t.end());     for (int i = 0; i < t.length(); i++) {       if (s[j] == t[i]) j++;       if (j == s.length()) {         r = t.length() - i;         break;       }     }     if (l >= r || l == -1 || r == -1)       cout << 0 << endl;     else       cout << r - l << endl;     return 0;   }   