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