#!/usr/bin/perl use strict; use warnings; my $str = <>; chomp $str; my @array = split //, $str; my $ans = 1; my $word = length $str; for(my $i = 1; $i < $word + 1; $i++) { $ans *= $i } for(my $i = 0; $i < $word - 1; $i++) { my $count = 1; for(my $j = $i + 1; $j < $word; $j++) { if($array[$i] eq $array[$j]) { $count++; } } $ans /= $count; } $ans--; print "$ans\n"; exit;