Under construction

Still being built. Things may change

Gyeongnodang Punk 2077

Time limit1sMemory limit1024 MB

Summary
Given the English-mode keystrokes of a Korean name typed on a 2-set keyboard, decide whether the last syllable has a final consonant.
Level

Medium4 of 10

Topics
String, Implementation
Solved
No attempts yet

Problem

Sieun is developing an open-world action Go-Stop game, Gyeongnodang Punk 2077, as a capstone project. While adding dialogue, Sieun realized that the game must print either '을' or '를' depending on the user's name. For example, if the name is 도현, it must print 도현'을', and if the name is 인하, it must print 인하'를'. The criterion is whether the last syllable of the name has a final consonant (batchim).

Users must use names made only of Hangul syllables. Every syllable of the name can be formed by picking one initial, one vowel, and one final in order from the table above. For example, the syllable 인 (initial ㅇ, vowel ㅣ, final ㄴ) and the syllable 하 (initial ㅎ, vowel ㅏ, no final) can appear in a user name. In contrast, 짜, 계, 와, and 삵 cannot appear in a user name, because each contains a jamo that is not in the table above.

Suppose a user types the name in English lowercase mode on the standard Korean 2-set keyboard shown in the figure. Call the resulting string ss. Given ss, write a program that determines whether the last syllable of the original user name has a final consonant.

Input

The first line contains an integer NN, the length of the string ss.

The second line contains the string ss.

Output

Print 1 if the last syllable of the user name has a final consonant. Otherwise, print 0.

Constraints

  • 2≤N≤302 \le N \le 30

Hint

The modern Hangul lists of initials, vowels, and finals are as follows.

  • Initials: ㄱ, ㄲ, ㄴ, ㄷ, ㄸ, ㄹ, ㅁ, ㅂ, ㅃ, ㅅ, ㅆ, ㅇ, ㅈ, ㅉ, ㅊ, ㅋ, ㅌ, ㅍ, ㅎ
  • Vowels: ㅏ, ㅐ, ㅑ, ㅒ, ㅓ, ㅔ, ㅕ, ㅖ, ㅗ, ㅘ, ㅙ, ㅚ, ㅛ, ㅜ, ㅝ, ㅞ, ㅟ, ㅠ, ㅡ, ㅢ, ㅣ
  • Finals: (none), ㄱ, ㄲ, ㄳ, ㄴ, ㄵ, ㄶ, ㄷ, ㄹ, ㄺ, ㄻ, ㄼ, ㄽ, ㄾ, ㄿ, ㅀ, ㅁ, ㅂ, ㅄ, ㅅ, ㅆ, ㅇ, ㅈ, ㅊ, ㅋ, ㅌ, ㅍ, ㅎ

However, for convenience in this problem, the kinds of initials, vowels, and finals that can appear in the input are restricted.

Examples3

  1. Example 1

    Input
    7
    wnehgus
    
    Expected output
    1
    
  2. Example 2

    Input
    8
    rlarudxo
    
    Expected output
    0
    
  3. Example 3

    Input
    10
    anzufutaba
    
    Expected output
    1