# PROBLEM LINK:

**Author:** Najiba Halim

**Tester:** Amitkumar Jha

**Editorialist:** Najiba Halim

# DIFFICULTY:

cakewalk

# PROBLEM:

One string will be provided as input. The string will only consist of characters C and S.

Value of C = count of S before it.

Value of S = Count of C after it.

Output the total values of all the characters.

# QUICK EXPLANATION:

Scan through the string twice, in 1st pass calculate the value of C’s and in other pass calculate the values of S’s

# EXPLANATION :

Construct 2 loops:

- For counting the value of all C’s
- For counting the values of all S’s

This can be done as Follows:

Initialize ans=0

The C loop:

Initialize s=0

Start counter i from 0 to n-1

If you encounter S, increment s

Else the value of C = s

Add it in the answer

The S loop:

Initialize c=0

Start counter i from n-1 to 0

If you encounter C, increment c

Else the value of S = c

Add it in the answer