Building a KOREA String
InterviewTime limit1sMemory limit1024 MB
Given a string of the letters K, O, R, E, A, find the length of the longest subsequence that spells KOREA repeatedly, starting with K.
- Level
Easy3 of 10
- Topics
- String, Dynamic programming
- Solved
- No attempts yet
Problem
The English name of Korea University is KOREA UNIVERSITY.
You are given a string consisting only of the uppercase letters K, O, R, E, and A. By deleting zero or more characters from , you want to build a string that starts with K and repeats the letters K, O, R, E, A in that order, such as "KOREAKOREAKOR". Call such a string a KOREA string.
Given the string, find the length of the longest KOREA string that you can build by deleting zero or more characters.
Input
The first line contains the string . consists only of the uppercase letters K, O, R, E, and A, and its length is between and , inclusive.
Output
On the first line, print the length of the longest KOREA string that you can build.