#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
    char[25];
    fgets(s, sizeof(s), stdin);
    S[strcspn(s, "\n")]='\0';
    for(inti=0; i<strlen(s);i++){
        if(!(isalpha(s[i])|| s[i] ==' '))
        {
            printf("Invalid Input\n");
            return 0;
        }
    }
    char *token=strtok(s, " ");
    char *lastword=NULL;
    while (token !=NULL){
        lastword = token;
        token = strtok(NULL, " ");
    }
    
    if(lastWord !=NULL){
        printf("%d\n",(int)strlen(lastWord));
    } else {
        printf("O\n");
    }
    return 0;
}