Under construction

Still being built. Things may change

Socks

Interview

Time limit2sMemory limit1024 MB

Summary
Given a string of B and C socks, count how many same-color pairs of socks can be formed.
Level

Easy1 of 10

Topics
String, Implementation
Solved
No attempts yet

Problem

In Bajtocja, wearing socks of different colors and patterns is no longer fashionable. The current trend is to wear exactly two white socks or exactly two black socks.

Bajtazar, who always follows the latest fashion, bought many single socks, both white and black. He wants to know how many pairs of socks of one color he can assemble from them.

Bajtazar is not good at counting his socks, so he asked you for help. Write a program that reads the string describing Bajtazar's socks and prints the number of single-color pairs that can be made from them.

Input

The only line of input contains a non-empty string of the letters B and C. B is a white sock and C is a black sock.

The length of the string does not exceed 1 000 000 characters.

Output

The only line of output contains one non-negative integer: the number of single-color pairs of socks that can be made from the socks described in the input.

Examples3

  1. Example 1

    Input
    BBCBCCBCB
    
    Expected output
    4
    
  2. Example 2

    Input
    CCCBC
    
    Expected output
    2
    
  3. Example 3

    Input
    CBCBCBCB
    
    Expected output
    4