// editor2
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 50
int top=-1;
char stack[MAX][MAX];
int size = 0;
int cnt=0;
int isEmpty(){
    return top==-1;
}
int isFull(){
    return top==size-1;
}

void push(char* ch){
    // if(isFull){
    //     printf("Stack overflow");
    //     return;
    // }else{
        strcpy(stack[++top],ch);
        
    // }
}
void display(){
    int itr;
    for(itr=size-1;itr>=0;itr--){
        printf("%s ",stack[itr]);
    }
}
int main(){
    scanf("%d",&size);
    
    for(int i=0;i<size;i++){
        char word[30];
        scanf("%s",word);
        if(word == ' '){
            cnt++;
        }
        push(word);
    }
    display();
    printf("%d",cnt);
    return 0;
}