E - Keyboard Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 7

問題文

高橋君は整数 N をキーボードを使って入力しようと考えています。
高橋君は各桁の数字のうち、1 , 2 , 3 , 4 , 5 は左手を用いて、6 , 7 , 8 , 9 , 0 は右手を用いて入力します。
高橋君が各桁の数字を打ち込むのにかかる時間は以下の通りです。

  • 打ち込みたい数字が整数の先頭の桁であるとき、数字によらず 500ms かかる。
  • そうでなく、打ち込みたい数字が直前の数字と同じであるとき、301ms かかる。
  • 上の 2 つに該当せず、打ち込みたい数字が直前の数字を打ち込むのに用いた手と同一の手を用いるとき、210ms かかる。
  • それ以外のとき、100ms かかる。

整数を入力するのにかかる時間は各桁を打ち込むのにかかる時間の総和です。高橋君が整数 N を入力するのにかかる時間が何 ms であるか求めてください。

制約

  • 1 \leq N < 10^{200000}
  • N の先頭の桁は 0 ではない。
  • N は整数

入力

入力は以下の形式で標準入力から与えられる。

N

出力

答えを出力せよ。


入力例 1

1120

出力例 1

1111
  • まず、先頭の桁 1 を打ち込むのに 500ms かかります。
  • 次の桁も 1 であり、これは直前の数字と同じ数字であるため、これを打ち込むのに 301ms かかります。
  • その次の桁は 2 であり、これは直前の数字と異なる数字ですが、どちらも左手を用いて打ち込む数字であるため、これを打ち込むのに 210ms かかります。
  • 最後の桁は 0 であり、これは直前の数字と異なり、打ち込むのに用いる手も異なるため、これを打ち込むのに 100ms かかります。

よって、1120 を打ち込むのには合計で 500+301+210+100=1111ms かかります。


入力例 2

8

出力例 2

500

N1 桁のみからなるため、打ち込むのにかかる時間は先頭の桁の数字を打ち込むのにかかる時間と等しく、500ms となります。


入力例 3

12345678901234567890

出力例 3

4160

Score : 7 points

Problem Statement

Takahashi will enter an integer N using a keyboard.
When entering the digits, he will use the left hand for 1, 2, 3, 4, 5, and the right hand for 6, 7, 8, 9, 0.
The time it takes for him to enter each digit is as follows.

  • If the digit to enter is the top digit of the integer, it takes 500 milliseconds, regardless of what that digit is.
  • Otherwise, if the digit to enter is the same as the previous digit, it takes 301 milliseconds.
  • If none of the above applies, and the digit to enter is entered by the same hand as the hand used to enter the previous digit, it takes 210 milliseconds.
  • If none of the above applies, it takes 100 milliseconds.

The total time to enter the integer is the sum of the times to enter the respective digits. Print the time it takes for Takahashi to enter the integer N, in milliseconds.

Constraints

  • 1 \leq N < 10^{200000}
  • The top digit of N is not 0.
  • N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer.


Sample Input 1

1120

Sample Output 1

1111
  • First, it takes 500 milliseconds to enter the top digit 1.
  • The next digit is 1, which is the same digit as the previous, so it takes 301 milliseconds to enter it.
  • The next digit is 2, which is a different digit from the previous but entered by the left hand again, so it takes 210 milliseconds to enter it.
  • The last digit is 0, which is a different digit from the previous and entered by the other hand, so it takes 100 milliseconds to enter it.

Therefore, it takes a total of 500+301+210+100=1111 milliseconds to enter 1120.


Sample Input 2

8

Sample Output 2

500

N has just one digit, so the time it takes to enter it is equal to the time it takes to enter the top digit, which is 500 milliseconds.


Sample Input 3

12345678901234567890

Sample Output 3

4160