#K73422. Treasure Hunter's Quest
Treasure Hunter's Quest
Treasure Hunter's Quest
In this problem, you are given a representation of a valley which is divided into n segments. Each segment is represented by a character:
- T: a treasure
- O: an obstacle
- .: an empty segment
Formally, let (n) be the length of the valley and (s) be the string representing the valley. The hunter collects all treasures before the first obstacle. When the first obstacle is met, he may choose to jump it and then begin collecting treasures thereafter until he encounters another obstacle, which terminates his journey. Your task is to determine the maximum number of treasures the hunter can collect.
Note: The input is provided via standard input (stdin) and the output should be printed to standard output (stdout).
inputFormat
The input consists of two lines:
- The first line contains a single integer \(n\) (\(1 \leq n \leq 10^5\)), representing the length of the valley.
- The second line is a string of length \(n\) consisting of characters 'T', 'O', and '.', representing treasures, obstacles, and empty segments respectively.
outputFormat
Print a single integer representing the maximum number of treasures the hunter can collect.## sample
7
T..O.TT
3