Mock CCC '19 Contest 2 J1 - Tudor Drinks Some Tea

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 1.0s
Memory limit: 1G

Problem type

Tudor, having somehow survived yet another exam season, has decided to celebrate by preparing himself a cup of tea. Little did he know that someone snuck in some tapioca pearls into his tea. Poor Tudor, being forced to consume tapioca pearls with his tea.

Because Tudor still hasn't shaken off drinking tea from his brief stint during the summer in the United States, he consumes his tea with a straw. He begins to consume some tea via the straw. How many tapioca pearls is he going to ingest based on the contents of the straw right now?


In tests worth 5 marks, there will be at most one pearl in the straw.

Input Specification

The input will contain five lines, each one corresponding to a part of the straw. For our purposes, we will assume that a tapioca pearl, if present, takes up volume equal to exactly one part of the straw.

Each line will contain a single uppercase letter, either a T to indicate that the vertical cross-section of that part of the straw will contain only tea or a P to indicate that it will contain a single tapioca pearl.

Output Specification

Output, on a single line, the number of tapioca pearls currently in the straw.

Sample Input


Sample Output


Sample Explanation

Tudor's about to consume five tapioca pearls with the current strawful of tea. How will he survive?


  • 2
    Miss  commented on Oct. 18, 2019, 3:36 p.m. edited

    I am having the same problem using Python 3. I tried using print(x, end='') and sys.stdout.write(pearls) but am still getting the whitespace error.

    • 0
      p1geon  commented on Oct. 18, 2019, 10:10 p.m.

      your code passes if you just print(pearls)

    • -2
      hxxr  commented on Oct. 18, 2019, 9:14 p.m.

      Have you tried putting a newline character at the end of the output?

      i.e. don't use end=''

      • 2
        Miss  commented on Oct. 22, 2019, 12:32 p.m. edited

        Ah, there should be a newline character! Thank you, hxxr :) And p!geon!!