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