#!/usr/bin/perl -w

use v5.30;
use strict;

chomp (my $data = <>);

my $re = join('|', map { ("\l$_\u$_", "\u$_\l$_") } ('a' .. 'z'));

my $min;
for my $c ('a' .. 'z') {
	my $d1 = $data;
	$d1 =~ s/$_//g for $c, "\u$c";
	1 while $d1 =~ s/$re//;
	$min = length $d1 if !$min || $min > length $d1;
}

say $min;

