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


// TODO: Implement a helper named check_permissions that matches the prototype below.
int check_permissions(char *perm1, char *perm2){
    for(int i = 0; i < 10; i++){
        if (perm2[i] == '-'){
            continue;
        }
        if (perm1[i] != perm2[i]){
            return 0;
        }
    }
    return 1;
};


int main(int argc, char** argv) {
    if (!(argc == 2 || argc == 3)) {
        fprintf(stderr, "USAGE: count_large size [permissions]\n");
        return 1;
    }

    // TODO: Process command line arguments.
    
    char *perms = "----------";
    int sizeLimit = atol(argv[1]);

    // TODO: Call check_permissions as part of your solution to count the files to
    // compute and print the correct value.
    if (argc == 3) {
        for (int i = 0; i < 10; i++) {
                perms[i] = argv[2][i];
        }
    }
    char *permissions = malloc(10 * sizeof(char));
    int size;
    scanf("%*s %*d");
    int biggerFiles = 0;
    while (scanf("%s %*d %*s %*s %d %*s %*d %*s %*s", permissions, &size) == 2) {
        if (size > sizeLimit) {
            if (check_permissions(permissions, perms)) {
                    biggerFiles++;
            }
        }
    }
    printf("%d \n", biggerFiles);

    return 0;
}

work