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