#include<stdio.h>
#include<string.h>
struct word {
    char str[100];
    char ch;
}; int count0ccurrences(struct word w) {
    int cound = 0;
    for(int i =0; 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("%", w.str);
    scanf("%c", &w.ch);
    int result = count0ccrrences(w);
    printf("%d", result);
    return 0;
}