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

open(my $fh, '<', 'input') or die "$!";
my $n;
for my $line (<$fh>) {
	chomp $line;
	my ($min, $max, $goal, $pass) = $line =~ m{^(\d+)-(\d+) ([a-z]): ([a-z]+)};
	my $count = () = $pass =~ /$goal/g;
    if ($count <= $max && $count >= $min) {
        $n++;
    }
}
print "$n\n";
