#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QUE_LENGTH 100

struct queue{
	int head;
	int tail;
	char *array[QUE_LENGTH];
};

struct queue *create_queue(){
	struct queue* q = malloc(sizeof(struct queue));
	q->head = 0;
	q->tail = 0;
	return q;
}

void enqueue(struct queue *q, char *s){
	char *t = malloc(100);
	strcpy(t, s);
	q->array[q->tail] = t;
	if(q->tail == QUE_LENGTH)
		q->tail = 0;
	else
		q->tail++;
}

char *dequeue(struct queue *q){
	char* s = q->array[q->head];
	if(q->head == QUE_LENGTH)
		q->head = 0;
	else
		q->head++;
	return s;
}

int main(int argc, char *argv[]){
	int n = 10;
	char buffer[100];
	struct queue *q = create_queue();

	if(argc > 1){
		++argv;
		if(**argv == '-')
			n = atoi(++*argv);
	}
	printf("%d\n", n);
	while(fgets(buffer, 100, stdin)){
		enqueue(q, buffer);
	}
	while(n--){
		strcpy(buffer, dequeue(q));
		printf("%s\n", buffer);
	}
	return 0;
}