Under construction

Still being built. Things may change

Dokkaebi-bul

Time limit1sMemory limit1024 MB

Summary
Given a string typed in English mode on a 2-set keyboard, count how many times the Dokkaebi-bul phenomenon occurs when it is typed in Korean mode.
Level

Medium4 of 10

Topics
String, Simulation, Implementation
Solved
No attempts yet

Problem

2-set and QWERTY keyboard

When you type Korean on a 2-set keyboard, you can run into an unusual effect called the Dokkaebi-bul phenomenon. Other input methods rarely show it. For example, follow each keystroke while typing 서강대학교:

ㅅ
서
석
서가
서강
서강ㄷ
서강대
서강댛
서강대하
서강대학
서강대학ㄱ
서강대학교

When '석' changes to '서가', the consonant that will become the initial of the next syllable attaches first to the final position of the syllable being typed. This is called the Dokkaebi-bul phenomenon.

Typing 서강대학교 causes the Dokkaebi-bul phenomenon twice. Here are more examples.

InputEnglish-mode keysCount
이보세요dlqhtpdy3
코딩하기 싫다zheldgkrl tlfgek2
마춤뻐비 틀려써요akcnaQjql xmffuTjdy4
  • 이보세요: ('입' to '이보'), ('이봇' to '이보세'), ('이보셍' to '이보세요')
  • 코딩하기 싫다: ('콛' to '코딩'), ('코딩학' to '코딩하기')
  • 마춤뻐비 틀려써요: ('맟' to '마추'), ('마춤뻡' to '마춤뻐비'), ('마춤뻐비 틀렸' to '마춤뻐비 틀려써'), ('마춤뻐비 틀려썽' to '마춤뻐비 틀려써요')

Given a string, count how many Dokkaebi-bul phenomena occur when you type that string on the keyboard.

Input

The first line contains a Korean string made of spaces and precomposed Hangul syllables, written as the keys typed in English input mode. The length of the string is at least 1 and at most 10410^4.

Output

Print the number of Dokkaebi-bul phenomena that occur when the given string is typed in Korean input mode.

Hint

Initialㄱㄲㄴㄷㄸㄹㅁㅂ
English keyrRseEfaq
Initialㅃㅅㅆㅇㅈㅉㅊㅋ
English keyQtTdwWcz
Initialㅌㅍㅎ
English keyxvg
Vowelㅏㅐㅑㅒㅓㅔㅕㅖ
English keykoiOjpuP
Vowelㅗㅘㅙㅚㅛㅜㅝㅞ
English keyhhkhohlynnjnp
Vowelㅟㅠㅡㅢㅣ
English keynlbmmll
Finalㄱㄲㄳㄴㄵㄶㄷㄹ
English keyrRrtsswsgef
Finalㄺㄻㄼㄽㄾㄿㅀㅁ
English keyfrfafqftfxfvfga
Finalㅂㅄㅅㅆㅇㅈㅊㅋ
English keyqqttTdwcz
Finalㅌㅍㅎ
English keyxvg

Double consonants ㄲ, ㄸ, ㅃ, ㅆ, ㅉ correspond to R, E, Q, T, W, respectively, and cannot be typed the way rr, ee, qq, tt, ww would be.

There are 19 initial consonants, 21 vowels, and 27 final consonants.

Refer to the 2-set keyboard image above for the key layout. (Korean keys follow 2-set, English keys follow QWERTY.)

Examples3

  1. Example 1

    Input
    dlqhtpdy
    
    Expected output
    3
    
  2. Example 2

    Input
    zheldgkrl tlfgek
    
    Expected output
    2
    
  3. Example 3

    Input
    akcnaQjql xmffuTjdy
    
    Expected output
    4