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

my @groups;
open(my $fh, '<', 'input') or die "$!";
{
    local $/;
    my $content = <$fh>;
    @groups = split("\n\n", $content);
}

# reduce each group to a bag o words, then uniq, count
my $n;
for my $g (@groups) {
    my %yes;
    for my $m (split("\n", $g)) {
        chomp($m);
        $yes{$_} = 1 for split('', $m);
    }
    $n += keys %yes;
}
print "$n\n";
