loop do
	str = gets.chomp.to_s
	break if str == "#"
	str_tmp = str
	ss = str_tmp.chars
	left = "asdfqwerzxcvbgt"
	right = "poiuylkjhmn"
	left = left.chars
	right = right.chars
	cnt = 0
	flag = 0
	ss.each do |sss|
		left.each do |l|
			if l == sss && flag != 1
				cnt += 1
				flag = 1
			end
		end
		right.each do |r|
			if r == sss && flag != 2
				flag = 2 
				cnt += 1
			end
		end
	end
	p cnt-1
end