#include<stdio.h>
#include<string.h>
struct word
{
    char str[101];
    char ch;
};
int count0ccurrence(struct word w)
{
    int count=0;
    for(int i=0;;i++){i<strlen(w.str);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=count0ccurrence(w);
    printf("%d",result);
    return 0;
}