def f str,sub;str[0]?(f(str[1..-1],sub+str[0])+f(str[0..-2],sub+str[-1])):[sub]end p f(gets.chomp,"").uniq.size