#K35207. Minimum Operations to Transform a Single Character to PYTHON

    ID: 25480 Type: Default 1000ms 256MiB

Minimum Operations to Transform a Single Character to PYTHON

Minimum Operations to Transform a Single Character to PYTHON

You are given a single uppercase English letter which is guaranteed to be one of the letters in the string PYTHON. Your task is to compute the minimum number of operations required to transform the given character into the full word PYTHON.

The transformation is defined as follows:

  • If the input character is P, you only need to append the remaining letters Y, T, H, O, N to form PYTHON, which takes 5 operations.
  • If the input character is not P, you must first replace it with P (1 operation) and then append the 5 remaining letters, taking a total of 6 operations.

In mathematical notation, let \( S \) be the starting character and \( T = \text{PYTHON} \). Then, the number of operations \( N(S) \) is given by:

[ N(S) = \begin{cases} 5, & \text{if } S = P \ 6, & \text{otherwise} \end{cases} ]

Your solution should read the starting character from standard input and print the minimum number of operations to standard output.

inputFormat

The input consists of a single line containing one uppercase letter which is one of 'P', 'Y', 'T', 'H', 'O', 'N'.

outputFormat

Output a single integer representing the minimum number of operations required to form the word "PYTHON".## sample

P
5