#include <bits/stdc++.h>   using namespace std;   char s[1005];   char t[1000005];   int main() {     scanf( %s , s);     scanf( %s , t);     int len1 = strlen(s);     int len2 = strlen(t);     int le = 0x3f3f3f3f;     int ri = 0x3f3f3f3f;     for (int i = 0, j = 0; j < len2; j++) {       if (s[i] == t[j]) i++;       if (i == len1) {         le = j;         break;       }     }     for (int i = len1 - 1, j = len2 - 1; j >= 0; j--) {       if (s[i] == t[j]) i--;       if (i == -1) {         ri = j;         break;       }     }     if ((le - ri) == (len1 - 1))       cout <<  0  << endl;     else {       int ans = ri - le;       cout << ans << endl;     }   }   