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

open(my $fh, '<', 'input') or die "$!";
my $n;
for my $line (<$fh>) {
    my ($A, $B, $goal, $pass) = $line =~ m{^(\d+)-(\d+) ([a-z]): ([a-z]+)};
    if ((substr($pass, $A-1, 1) eq $goal) xor (substr($pass, $B-1, 1) eq $goal)) {
        $n++;
    }
}
print "$n\n";
