#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
    char s[21];
    fgets(s,sizeof(s),stdin);
    //Remove the newline character if present
    s[strcspn(s,"\n")]='\0';
    int len =strlen(s);
    
    for(int i=0;i<len;i++)
    {
        if(!isalpha(s[i]) && s[i] !=' ')
        {
            printf("Invalid input\n");
            return 0;
        }
    }
    int lastWordLength=0;
    int foundSpace=0;
    for (int i=len-1;i>=0;i--)
    {
        if(isalpha(s[i]))
        {
            lastWordLenght++;
            foundSpace=1;
        }else if(s[i]==' ' && foundSpace)
        {
            break;
        }
    }
    printf("%d\n",lastWordLength);
    return 0;
    
}