> perl -ple'$_=join"",sort split//;y///cs;$_=length' 1987 4 1988 3 2012 3 2013 4