Chef likes playing with strings. The most interesting game are named "CHEF in string". The move of the game consists of the following: Chef takes a subsequence of string's letters that form the word "CHEF" and then he removes that symbols. The goal of the game is to make the maximal number of moves. Please, help Chef and tell him the maximal possible number of moves that he is able to make for the given string S.

Input
 The first line of each test case contains a given string. This string consists of uppercase letters from the set {"C", "H", "E", "F"}. 

Output
Output a single line containing the maximal possible number of moves.

Constraints

1  ≤ |S| ≤ 100000


Example
Input:
CHEFCHEFFFF

Output:
2

Input:
CHHHEEEFFCC

Output:
1


Scoring
Subtask 1 (25 points): |S| ≤ 2000 
Subtask 2 (75 points):  See the constraints.
varC = varH = varE = varF = 0
for x in raw_input():
	if x == 'C':
		varC += 1
	elif x == 'H' and varC > varH:
		varH += 1
	elif x == 'E' and varH > varE:
		varE += 1
	elif x == 'F' and varE > varF:
		varF += 1
print varF