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

#include "node.h"



int list_length(struct node *head) {
    // This function is BUGGY. Find and fix the two bugs.
    int count = 0;
    struct node *curr = head;
    while (curr->next != NULL) {
        count++;
        curr = curr->next;
    }
    return count;
}


int main(void) {
    int n;
    if (scanf("%d", &n) != 1) { n = 0; }
    int arr[1000];
    for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); }
    struct node *head = build_list(arr, n);
    printf("%d\n", list_length(head));
    free_list(head);
    return 0;
}
