#include <bits/stdc++.h>
using namespace std;

int main() 
{
    string s1 , s2;
    cin>>s1>>s2;

    int i=0 , j=0;
    while(i < s1.size() && j < s2.size())
    {
        if(s1[i]==s2[j]) // when both the characters matches 
        {
            // move both the pointers 
            i++;
            j++;
        }
        else // else there are not matching
        {
            i++; // we will do i++
        }
    }

    // s1 = a b c z
    // s2 = a z d b 
    // size of s2 string is 4 
    // a z d b
    //        j
    // 'j' is pointing at index 2  in s2 
    // 4 - 2 = 2
    // ans = 2
    int ans = s2.size() - j;
    cout<<ans<<" ";
    

    return 0;
}
/*
abcz
azdb

o/p: 2
*/