#include<stdio.h>
#include<stdio.h>
#include<ctype.h>
int main(){
    char s[25];
    fgets(s, sizeof(s), stdin);
    s[strcspn(s, "\n")]= '\0';
    for (int i = 0; s[i] i++) {
        if (!isalpha(s[i]) && !isspace(s[i])){
            printf("Invalid input");
            return 0;
        }
        
    }
    int len = strlen(s),count = 0;
    int i = len - 1;
    while(i >=0 && isspace(s[i])) i--;
    while(i >=0 && isalpha(s[i])){
        count++;
        i--;
    }
    printf("%d", count);
    return 0 ;

}