include [HTML_REMOVED]
using namespace std;
int main()
{
string str;
string s,s1,s2;
cin >> str;
int a1 = str.find(“,”);
s=str.substr(0,a1);
int a2 = str.rfind(“,”);
s1 = str.substr(a1+1,a2-a1-1);
s2 = str.substr(a2+1);
int b1 = s.find(s1);
int b2 = s.rfind(s2);
if(b1!=-1 && b2!=-1 && b1+s1.size()-1<b2)
{
cout <<b2-(b1+s1.size());
}
else cout <<"-1";
return 0;
}