#include<stdio.h>
#include<string.h>
struct word
{
    char str[100];
    char ch;
};
int count0currencies(struct word w)
{
    int count=0;
    for(int i=0;i<strlen(w.ch);i++)
    {
        if(w,str[i]==w.ch)
        count++;
    }
    if(count==0)
    return-1;
    else
    return count;
}
int main()
{
    struct word w;
    scanf("%s",w.str);
    scanf("%c",&w.ch);
    int result=count0currences(w);
    printf("%d",result);
    return 0;
}