#!/usr/bin/perl -w

use v5.36;
use strict;

my @cubes = map { [ /(\d+)/g ] } <>;
my %cubes = map { join(',', @$_) => 1 } @cubes;

my $common;
for my $cube (@cubes) {
	for my $axis (0 .. 2) {
		for my $add (-1, 1) {
			my @neigh = @$cube;
			$neigh[$axis] += $add;
			$common++ if $cubes{join(',', @neigh)};
		}
	}
}
say 6*@cubes - $common;
