#!/usr/bin/perl -w

use strict;

my $count = 0;

while (<>) {
	my ($min, $max, $letter, $pass) = /\A(\d+)-(\d+)\s+(\S):\s+(\S+)\s*\z/;
	if (!defined $pass) {
		print "Divny radek $_\n";
		next;
	}

	
	my $chars =()= ($pass =~ /$letter/g);

	# print "$min-$max $letter: [$pass] - $chars\n";
	$count++ if $chars >= $min && $chars <= $max;
}

print $count, "\n";

