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