#!/usr/bin/env perl
use strict;
use warnings;

open(my $fh, '<', 'input') or die "$!";
# slurp
my $content;
{
    local $/;
    $content = <$fh>;
}

my @recs = split("\n\n", $content);
my $n;
my @required = qw(byr iyr eyr hgt hcl ecl pid);
REC:
for my $r (@recs) {

	my @fields = split(/\s+/, $r);
	my %has = map { $_ => 1 } map { $_ =~ s/:.*//r } @fields;
	for my $req (@required) {
		next REC if !exists $has{$req};
	}
	$n++;
}
print "$n\n";
