S = gets.chomp counter = Array.new(26, 0) ans = 0 S.each_char do |s| ('A'..'Z').each do |c| next if s == c cnt = counter[c.ord - 'A'.ord] next if cnt <= 1 ans += cnt * (cnt - 1) / 2 end counter[s.ord - 'A'.ord] += 1 end puts ans