#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main(){
    char s[21];
    scanf("%20[^\n", s);
    
    if (strlen(s)>20){
        printf("Invalid input");
        return 0;
    }
    
    for (int i=0; s[i]; i++)
        if (!isalnum(s[i]) && !isspace(s[i])){
            printf("Invalid input");
            return 0;
        }
    char *token = strtok(s, " ");
    char *lastword=NULL;
    
    while (token){
        lastword = token;
        token= strtok(NULL," ");
    }
    printf("%lu",strlen(lastword));
    return 0;
}