Score: <var>400</var> points

Problem Statement

There is a cave.

The cave has <var>N</var> rooms and <var>M</var> passages. The rooms are numbered <var>1</var> to <var>N</var>, and the passages are numbered <var>1</var> to <var>M</var>. Passage <var>i</var> connects Room <var>A_i</var> and Room <var>B_i</var> bidirectionally. One can travel between any two rooms by traversing passages. Room <var>1</var> is a special room with an entrance from the outside.

It is dark in the cave, so we have decided to place a signpost in each room except Room <var>1</var>. The signpost in each room will point to one of the rooms directly connected to that room with a passage.

Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room <var>1</var>.

If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room <var>1</var> after traversing the minimum number of passages possible.

Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.

Constraints

All values in input are integers.

<var>2 \leq N \leq 10^5</var>

<var>1 \leq M \leq 2 \times 10^5</var>

<var>1 \leq A_i, B_i \leq N\ (1 \leq i \leq M)</var>

<var>A_i \neq B_i\ (1 \leq i \leq M)</var>

One can travel between any two rooms by traversing passages.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>A_1</var> <var>B_1</var>
<var>:</var>
<var>A_M</var> <var>B_M</var>

Output

If there is no way to place signposts satisfying the objective, print No.

Otherwise, print <var>N</var> lines. The first line should contain Yes, and the <var>i</var>-th line <var>(2 \leq i \leq N)</var> should contain the integer representing the room indicated by the signpost in Room <var>i</var>.

Sample Input 1

4 4
1 2
2 3
3 4
4 2

Sample Output 1

Yes
1
2
2

If we place the signposts as described in the sample output, the following happens:

Starting in Room <var>2</var>, you will reach Room <var>1</var> after traversing one passage: <var>(2) \to 1</var>. This is the minimum number of passages possible.

Starting in Room <var>3</var>, you will reach Room <var>1</var> after traversing two passages: <var>(3) \to 2 \to 1</var>. This is the minimum number of passages possible.

Starting in Room <var>4</var>, you will reach Room <var>1</var> after traversing two passages: <var>(4) \to 2 \to 1</var>. This is the minimum number of passages possible.

Thus, the objective is satisfied.

Sample Input 2

6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6

Sample Output 2

Yes
6
5
5
1
1

If there are multiple solutions, any of them will be accepted.


Score : <var>400</var> points

Problem Statement

Takahashi has a string <var>S</var> consisting of lowercase English letters.

Starting with this string, he will produce a new one in the procedure given as follows.

The procedure consists of <var>Q</var> operations. In Operation <var>i</var> <var>(1 \leq i \leq Q)</var>, an integer <var>T_i</var> is provided, which means the following:

If <var>T_i = 1</var>: reverse the string <var>S</var>.

If <var>T_i = 2</var>: An integer <var>F_i</var> and a lowercase English letter <var>C_i</var> are additionally provided.

If <var>F_i = 1</var> : Add <var>C_i</var> to the beginning of the string <var>S</var>.

If <var>F_i = 2</var> : Add <var>C_i</var> to the end of the string <var>S</var>.

Help Takahashi by finding the final string that results from the procedure.

Constraints

<var>1 \leq |S| \leq 10^5</var>

<var>S</var> consists of lowercase English letters.

<var>1 \leq Q \leq 2 \times 10^5</var>

<var>T_i = 1</var> or <var>2</var>.

<var>F_i = 1</var> or <var>2</var>, if provided.

<var>C_i</var> is a lowercase English letter, if provided.

Input

Input is given from Standard Input in the following format:

<var>S</var>
<var>Q</var>
<var>Query_1</var>
<var>:</var>
<var>Query_Q</var>

In the <var>3</var>-rd through the <var>(Q+2)</var>-th lines, <var>Query_i</var> is one of the following:

<var>1</var>

which means <var>T_i = 1</var>, and:

<var>2</var> <var>F_i</var> <var>C_i</var>

which means <var>T_i = 2</var>.

Output

Print the resulting string.

Sample Input 1

a
4
2 1 p
1
2 2 c
1

Sample Output 1

cpa

There will be <var>Q = 4</var> operations. Initially, <var>S</var> is a.

Operation <var>1</var>: Add p at the beginning of <var>S</var>. <var>S</var> becomes pa.

Operation <var>2</var>: Reverse <var>S</var>. <var>S</var> becomes ap.

Operation <var>3</var>: Add c at the end of <var>S</var>. <var>S</var> becomes apc.

Operation <var>4</var>: Reverse <var>S</var>. <var>S</var> becomes cpa.

Thus, the resulting string is cpa.

Sample Input 2

a
6
2 2 a
2 1 b
1
2 2 c
1
1

Sample Output 2

aabc

There will be <var>Q = 6</var> operations. Initially, <var>S</var> is a.

Operation <var>1</var>: <var>S</var> becomes aa.

Operation <var>2</var>: <var>S</var> becomes baa.

Operation <var>3</var>: <var>S</var> becomes aab.

Operation <var>4</var>: <var>S</var> becomes aabc.

Operation <var>5</var>: <var>S</var> becomes cbaa.

Operation <var>6</var>: <var>S</var> becomes aabc.

Thus, the resulting string is aabc.

Sample Input 3

y
1
2 1 x

Sample Output 3

xy


Score : <var>200</var> points

Problem Statement

For a string <var>S</var> consisting of the uppercase English letters P and D, let the doctoral and postdoctoral quotient of <var>S</var> be the total number of occurrences of D and PD in <var>S</var> as contiguous substrings. For example, if <var>S =</var> PPDDP, it contains two occurrences of D and one occurrence of PD as contiguous substrings, so the doctoral and postdoctoral quotient of <var>S</var> is <var>3</var>.

We have a string <var>T</var> consisting of P, D, and ?.

Among the strings that can be obtained by replacing each ? in <var>T</var> with P or D, find one with the maximum possible doctoral and postdoctoral quotient.

Constraints

<var>1 \leq |T| \leq 2 \times 10^5</var>

<var>T</var> consists of P, D, and ?.

Input

Input is given from Standard Input in the following format:

<var>T</var>

Output

Print one string with the maximum possible doctoral and postdoctoral quotient among the strings that can be obtained by replacing each ? in <var>T</var> with P or D.
If there are multiple such strings, you may print any of them.

Sample Input 1

PD?D??P

Sample Output 1

PDPDPDP

This string contains three occurrences of D and three occurrences of PD as contiguous substrings, so its doctoral and postdoctoral quotient is <var>6</var>, which is the maximum doctoral and postdoctoral quotient of a string obtained by replacing each ? in <var>T</var> with P or D.

Sample Input 2

P?P?

Sample Output 2

PDPD


Score: <var>100</var> points

Problem Statement

The cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese.

When counting pencils in Japanese, the counter word "本" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of "本" in the phrase "<var>N</var> 本" for a positive integer <var>N</var> not exceeding <var>999</var> is as follows:

hon when the digit in the one's place of <var>N</var> is <var>2</var>, <var>4</var>, <var>5</var>, <var>7</var>, or <var>9</var>;

pon when the digit in the one's place of <var>N</var> is <var>0</var>, <var>1</var>, <var>6</var> or <var>8</var>;

bon when the digit in the one's place of <var>N</var> is <var>3</var>.

Given <var>N</var>, print the pronunciation of "本" in the phrase "<var>N</var> 本".

Constraints

<var>N</var> is a positive integer not exceeding <var>999</var>.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the answer.

Sample Input 1

16

Sample Output 1

pon

The digit in the one's place of <var>16</var> is <var>6</var>, so the "本" in "<var>16</var> 本" is pronounced pon.

Sample Input 2

2

Sample Output 2

hon

Sample Input 3

183

Sample Output 3

bon


Score : <var>300</var> points

Problem Statement

There are <var>N</var> people living on a number line.

The <var>i</var>-th person lives at coordinate <var>X_i</var>.

You are going to hold a meeting that all <var>N</var> people have to attend.

The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate <var>P</var>, the <var>i</var>-th person will spend <var>(X_i - P)^2</var> points of stamina to attend the meeting.

Find the minimum total points of stamina the <var>N</var> people have to spend.

Constraints

All values in input are integers.

<var>1 \leq N \leq 100</var>

<var>1 \leq X_i \leq 100</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>X_1</var> <var>X_2</var> <var>...</var> <var>X_N</var>

Output

Print the minimum total stamina the <var>N</var> people have to spend.

Sample Input 1

2
1 4

Sample Output 1

5

Assume the meeting is held at coordinate <var>2</var>. In this case, the first person will spend <var>(1 - 2)^2</var> points of stamina, and the second person will spend <var>(4 - 2)^2 = 4</var> points of stamina, for a total of <var>5</var> points of stamina. This is the minimum total stamina that the <var>2</var> people have to spend.

Note that you can hold the meeting only at an integer coordinate.

Sample Input 2

7
14 14 2 13 56 2 37

Sample Output 2

2354


Score : <var>300</var> points

Problem Statement

There is a staircase with <var>N</var> steps. Takahashi is now standing at the foot of the stairs, that is, on the <var>0</var>-th step.
He can climb up one or two steps at a time.

However, the treads of the <var>a_1</var>-th, <var>a_2</var>-th, <var>a_3</var>-th, <var>\ldots</var>, <var>a_M</var>-th steps are broken, so it is dangerous to set foot on those steps.

How many are there to climb up to the top step, that is, the <var>N</var>-th step, without setting foot on the broken steps?
Find the count modulo <var>1\ 000\ 000\ 007</var>.

Constraints

<var>1 \leq N \leq 10^5</var>

<var>0 \leq M \leq N-1</var>

<var>1 \leq a_1 < a_2 < </var> <var>...</var> <var> < a_M \leq N-1</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>a_1</var>
<var>a_2</var>
<var> .</var>
<var> .</var>
<var> .</var>
<var>a_M</var>

Output

Print the number of ways to climb up the stairs under the condition, modulo <var>1\ 000\ 000\ 007</var>.

Sample Input 1

6 1
3

Sample Output 1

4

There are four ways to climb up the stairs, as follows:

<var>0 \to 1 \to 2 \to 4 \to 5 \to 6</var>

<var>0 \to 1 \to 2 \to 4 \to 6</var>

<var>0 \to 2 \to 4 \to 5 \to 6</var>

<var>0 \to 2 \to 4 \to 6</var>

Sample Input 2

10 2
4
5

Sample Output 2

0

There may be no way to climb up the stairs without setting foot on the broken steps.

Sample Input 3

100 5
1
23
45
67
89

Sample Output 3

608200469

Be sure to print the count modulo <var>1\ 000\ 000\ 007</var>.


Score : <var>300</var> points

Problem Statement

Takahashi is organizing a party.

At the party, each guest will receive one or more snack pieces.

Takahashi predicts that the number of guests at this party will be <var>A</var> or <var>B</var>.

Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.

We assume that a piece cannot be divided and distributed to multiple guests.

Constraints

<var>1 \leq A, B \leq 10^5</var>

<var>A \neq B</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var>

Output

Print the minimum number of pieces that can be evenly distributed to the guests in both of the cases with <var>A</var> guests and <var>B</var> guests.

Sample Input 1

2 3

Sample Output 1

6

When we have six snack pieces, each guest can take three pieces if we have two guests, and each guest can take two if we have three guests.

Sample Input 2

123 456

Sample Output 2

18696

Sample Input 3

100000 99999

Sample Output 3

9999900000


Score : <var>100</var> points

Problem Statement

You will turn on the air conditioner if, and only if, the temperature of the room is <var>30</var> degrees Celsius or above.

The current temperature of the room is <var>X</var> degrees Celsius. Will you turn on the air conditioner?

Constraints

<var>-40 \leq X \leq 40</var>

<var>X</var> is an integer.

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

Print Yes if you will turn on the air conditioner; print No otherwise.

Sample Input 1

25

Sample Output 1

No

Sample Input 2

30

Sample Output 2

Yes


Score : <var>300</var> points

Problem Statement

Given are positive integers <var>N</var>, <var>M</var>, <var>Q</var>, and <var>Q</var> quadruples of integers ( <var>a_i</var> , <var>b_i</var> , <var>c_i</var> , <var>d_i</var> ).

Consider a sequence <var>A</var> satisfying the following conditions:

<var>A</var> is a sequence of <var>N</var> positive integers.

<var>1 \leq A_1 \leq A_2 \le \cdots \leq A_N \leq M</var>.

Let us define a score of this sequence as follows:

The score is the sum of <var>d_i</var> over all indices <var>i</var> such that <var>A_{b_i} - A_{a_i} = c_i</var>. (If there is no such <var>i</var>, the score is <var>0</var>.)

Find the maximum possible score of <var>A</var>.

Constraints

All values in input are integers.

<var>2 ≤ N ≤ 10</var>

<var>1 \leq M \leq 10</var>

<var>1 \leq Q \leq 50</var>

<var>1 \leq a_i < b_i \leq N</var> ( <var>i = 1, 2, ..., Q</var> )

<var>0 \leq c_i \leq M - 1</var> ( <var>i = 1, 2, ..., Q</var> )

<var>(a_i, b_i, c_i) \neq (a_j, b_j, c_j)</var> (where <var>i \neq j</var>)

<var>1 \leq d_i \leq 10^5</var> ( <var>i = 1, 2, ..., Q</var> )

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var> <var>Q</var>
<var>a_1</var> <var>b_1</var> <var>c_1</var> <var>d_1</var>
<var>:</var>
<var>a_Q</var> <var>b_Q</var> <var>c_Q</var> <var>d_Q</var>

Output

Print the maximum possible score of <var>A</var>.

Sample Input 1

3 4 3
1 3 3 100
1 2 2 10
2 3 2 10

Sample Output 1

110

When <var>A = \{1, 3, 4\}</var>, its score is <var>110</var>. Under these conditions, no sequence has a score greater than <var>110</var>, so the answer is <var>110</var>.

Sample Input 2

4 6 10
2 4 1 86568
1 4 0 90629
2 3 0 90310
3 4 1 29211
3 4 3 78537
3 4 2 8580
1 2 1 96263
1 4 2 2156
1 2 0 94325
1 4 3 94328

Sample Output 2

357500

Sample Input 3

10 10 1
1 10 9 1

Sample Output 3

1


Score : <var>100</var> points

Problem Statement

There are <var>N</var> stones, numbered <var>1, 2, \ldots, N</var>.
For each <var>i</var> (<var>1 \leq i \leq N</var>), the height of Stone <var>i</var> is <var>h_i</var>.

There is a frog who is initially on Stone <var>1</var>.
He will repeat the following action some number of times to reach Stone <var>N</var>:

If the frog is currently on Stone <var>i</var>, jump to one of the following: Stone <var>i + 1, i + 2, \ldots, i + K</var>. Here, a cost of <var>|h_i - h_j|</var> is incurred, where <var>j</var> is the stone to land on.

Find the minimum possible total cost incurred before the frog reaches Stone <var>N</var>.

Constraints

All values in input are integers.

<var>2 \leq N \leq 10^5</var>

<var>1 \leq K \leq 100</var>

<var>1 \leq h_i \leq 10^4</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>
<var>h_1</var> <var>h_2</var> <var>\ldots</var> <var>h_N</var>

Output

Print the minimum possible total cost incurred.

Sample Input 1

5 3
10 30 40 50 20

Sample Output 1

30

If we follow the path <var>1</var> → <var>2</var> → <var>5</var>, the total cost incurred would be <var>|10 - 30| + |30 - 20| = 30</var>.

Sample Input 2

3 1
10 20 10

Sample Output 2

20

If we follow the path <var>1</var> → <var>2</var> → <var>3</var>, the total cost incurred would be <var>|10 - 20| + |20 - 10| = 20</var>.

Sample Input 3

2 100
10 10

Sample Output 3

0

If we follow the path <var>1</var> → <var>2</var>, the total cost incurred would be <var>|10 - 10| = 0</var>.

Sample Input 4

10 4
40 10 20 70 80 10 20 70 80 60

Sample Output 4

40

If we follow the path <var>1</var> → <var>4</var> → <var>8</var> → <var>10</var>, the total cost incurred would be <var>|40 - 70| + |70 - 70| + |70 - 60| = 40</var>.


Score : <var>100</var> points

Problem Statement

<var>N</var> of us are going on a trip, by train or taxi.

The train will cost each of us <var>A</var> yen (the currency of Japan).

The taxi will cost us a total of <var>B</var> yen.

How much is our minimum total travel expense?

Constraints

All values in input are integers.

<var>1 \leq N \leq 20</var>

<var>1 \leq A \leq 50</var>

<var>1 \leq B \leq 50</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>A</var> <var>B</var>

Output

Print an integer representing the minimum total travel expense.

Sample Input 1

4 2 9

Sample Output 1

8

The train will cost us <var>4 \times 2 = 8</var> yen, and the taxi will cost us <var>9</var> yen, so the minimum total travel expense is <var>8</var> yen.

Sample Input 2

4 2 7

Sample Output 2

7

Sample Input 3

4 2 8

Sample Output 3

8


Score : <var>100</var> points

Problem Statement

Snuke is going to open a contest named "AtCoder <var>s</var> Contest".
Here, <var>s</var> is a string of length <var>1</var> or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters.

Snuke has decided to abbreviate the name of the contest as "A<var>x</var>C".
Here, <var>x</var> is the uppercase English letter at the beginning of <var>s</var>.

Given the name of the contest, print the abbreviation of the name.

Constraints

The length of <var>s</var> is between <var>1</var> and <var>100</var>, inclusive.

The first character in <var>s</var> is an uppercase English letter.

The second and subsequent characters in <var>s</var> are lowercase English letters.

Input

The input is given from Standard Input in the following format:

AtCoder <var>s</var> Contest

Output

Print the abbreviation of the name of the contest.

Sample Input 1

AtCoder Beginner Contest

Sample Output 1

ABC

The contest in which you are participating now.

Sample Input 2

AtCoder Snuke Contest

Sample Output 2

ASC

This contest does not actually exist.

Sample Input 3

AtCoder X Contest

Sample Output 3

AXC


Score : <var>300</var> points

Problem Statement

You are given an integer <var>N</var>.

For two positive integers <var>A</var> and <var>B</var>, we will define <var>F(A,B)</var> as the larger of the following: the number of digits in the decimal notation of <var>A</var>, and the number of digits in the decimal notation of <var>B</var>.

For example, <var>F(3,11) = 2</var> since <var>3</var> has one digit and <var>11</var> has two digits.

Find the minimum value of <var>F(A,B)</var> as <var>(A,B)</var> ranges over all pairs of positive integers such that <var>N = A \times B</var>.

Constraints

<var>1 \leq N \leq 10^{10}</var>

<var>N</var> is an integer.

Input

The input is given from Standard Input in the following format:

<var>N</var>

Output

Print the minimum value of <var>F(A,B)</var> as <var>(A,B)</var> ranges over all pairs of positive integers such that <var>N = A \times B</var>.

Sample Input 1

10000

Sample Output 1

3

<var>F(A,B)</var> has a minimum value of <var>3</var> at <var>(A,B)=(100,100)</var>.

Sample Input 2

1000003

Sample Output 2

7

There are two pairs <var>(A,B)</var> that satisfy the condition: <var>(1,1000003)</var> and <var>(1000003,1)</var>. For these pairs, <var>F(1,1000003)=F(1000003,1)=7</var>.

Sample Input 3

9876543210

Sample Output 3

6


Score : <var>300</var> points

Problem Statement

Takahashi has <var>N</var> balls. Initially, an integer <var>A_i</var> is written on the <var>i</var>-th ball.

He would like to rewrite the integer on some balls so that there are at most <var>K</var> different integers written on the <var>N</var> balls.

Find the minimum number of balls that Takahashi needs to rewrite the integers on them.

Constraints

<var>1 \leq K \leq N \leq 200000</var>

<var>1 \leq A_i \leq N</var>

All input values are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>
<var>A_1</var> <var>A_2</var> ... <var>A_N</var>

Output

Print the minimum number of balls that Takahashi needs to rewrite the integers on them.

Sample Input 1

5 2
1 1 2 2 5

Sample Output 1

1

For example, if we rewrite the integer on the fifth ball to <var>2</var>, there are two different integers written on the balls: <var>1</var> and <var>2</var>.
On the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print <var>1</var>.

Sample Input 2

4 4
1 1 2 2

Sample Output 2

0

Already in the beginning, there are two different integers written on the balls, so we do not need to rewrite anything.

Sample Input 3

10 3
5 1 3 2 4 1 1 2 3 4

Sample Output 3

3


Score: <var>200</var> points

Problem Statement

You are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.

According to the regulation, the immigrant should be allowed entry to the kingdom if and only if the following condition is satisfied:

All even numbers written on the document are divisible by <var>3</var> or <var>5</var>.

If the immigrant should be allowed entry according to the regulation, output APPROVED; otherwise, print DENIED.

Notes

The condition in the statement can be rephrased as "If <var>x</var> is an even number written on the document, <var>x</var> is divisible by <var>3</var> or <var>5</var>".
Here "if" and "or" are logical terms.

Constraints

All values in input are integers.

<var>1 \leq N \leq 100</var>

<var>1 \leq A_i \leq 1000</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var> <var>A_2</var> <var>\dots</var> <var>A_N</var>

Output

If the immigrant should be allowed entry according to the regulation, print APPROVED; otherwise, print DENIED.

Sample Input 1

5
6 7 9 10 31

Sample Output 1

APPROVED

The even numbers written on the document are <var>6</var> and <var>10</var>.

All of them are divisible by <var>3</var> or <var>5</var>, so the immigrant should be allowed entry.

Sample Input 2

3
28 27 24

Sample Output 2

DENIED

<var>28</var> violates the condition, so the immigrant should not be allowed entry.


Score : <var>100</var> points

Problem Statement

Snuke built an online judge to hold a programming contest.

When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string <var>S</var> as a contiguous substring.
(The judge can return any two-character substring of <var>S</var>.)

Determine whether the judge can return the string AC as the verdict to a program.

Constraints

<var>2 \leq |S| \leq 5</var>

<var>S</var> consists of uppercase English letters.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

If the judge can return the string AC as a verdict to a program, print Yes; if it cannot, print No.

Sample Input 1

BACD

Sample Output 1

Yes

The string AC appears in BACD as a contiguous substring (the second and third characters).

Sample Input 2

ABCD

Sample Output 2

No

Although the string ABCD contains both A and C (the first and third characters), the string AC does not appear in ABCD as a contiguous substring.

Sample Input 3

CABD

Sample Output 3

No

Sample Input 4

ACACA

Sample Output 4

Yes

Sample Input 5

XX

Sample Output 5

No


Score : <var>500</var> points

Problem Statement

There are <var>N</var> Snuke Cats numbered <var>1, 2, \ldots, N</var>, where <var>N</var> is even.

Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.

Recently, they learned the operation called xor (exclusive OR).

What is xor?

For <var>n</var> non-negative integers <var>x_1, x_2, \ldots, x_n</var>, their xor, <var>x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n</var> is defined as follows:

 When <var>x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n</var> is written in base two, the digit in the <var>2^k</var>'s place (<var>k \geq 0</var>) is <var>1</var> if the number of integers among <var>x_1, x_2, \ldots, x_n</var> whose binary representations have <var>1</var> in the <var>2^k</var>'s place is odd, and <var>0</var> if that count is even.

For example, <var>3~\textrm{xor}~5 = 6</var>.

They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.

We know that the xor calculated by Snuke Cat <var>i</var>, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat <var>i</var> is <var>a_i</var>.
Using this information, restore the integer written on the scarf of each Snuke Cat.

Constraints

All values in input are integers.

<var>2 \leq N \leq 200000</var>

<var>N</var> is even.

<var>0 \leq a_i \leq 10^9</var>

There exists a combination of integers on the scarfs that is consistent with the given information.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>a_1</var> <var>a_2</var> <var>\ldots</var> <var>a_N</var>

Output

Print a line containing <var>N</var> integers separated with space.

The <var>i</var>-th of the integers from the left should represent the integer written on the scarf of Snuke Cat <var>i</var>.

If there are multiple possible solutions, you may print any of them.

Sample Input 1

4
20 11 9 24

Sample Output 1

26 5 7 22

<var>5~\textrm{xor}~7~\textrm{xor}~22 = 20</var>

<var>26~\textrm{xor}~7~\textrm{xor}~22 = 11</var>

<var>26~\textrm{xor}~5~\textrm{xor}~22 = 9</var>

<var>26~\textrm{xor}~5~\textrm{xor}~7 = 24</var>

Thus, this output is consistent with the given information.


Score : <var>100</var> points

Problem Statement

There are <var>N</var> children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give <var>1</var> candy to the first child in the line, <var>2</var> candies to the second child, ..., <var>N</var> candies to the <var>N</var>-th child. How many candies will be necessary in total?

Constraints

<var>1≦N≦100</var>

Input

The input is given from Standard Input in the following format:

<var>N</var>

Output

Print the necessary number of candies in total.

Sample Input 1

3

Sample Output 1

6

The answer is <var>1+2+3=6</var>.

Sample Input 2

10

Sample Output 2

55

The sum of the integers from <var>1</var> to <var>10</var> is <var>55</var>.

Sample Input 3

1

Sample Output 3

1

Only one child. The answer is <var>1</var> in this case.


Score : <var>200</var> points

Problem Statement

We have <var>N</var> weights indexed <var>1</var> to <var>N</var>. The mass of the weight indexed <var>i</var> is <var>W_i</var>.

We will divide these weights into two groups: the weights with indices not greater than <var>T</var>, and those with indices greater than <var>T</var>, for some integer <var>1 \leq T < N</var>. Let <var>S_1</var> be the sum of the masses of the weights in the former group, and <var>S_2</var> be the sum of the masses of the weights in the latter group.

Consider all possible such divisions and find the minimum possible absolute difference of <var>S_1</var> and <var>S_2</var>.

Constraints

<var>2 \leq N \leq 100</var>

<var>1 \leq W_i \leq 100</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>W_1</var> <var>W_2</var> <var>...</var> <var>W_{N-1}</var> <var>W_N</var>

Output

Print the minimum possible absolute difference of <var>S_1</var> and <var>S_2</var>.

Sample Input 1

3
1 2 3

Sample Output 1

0

If <var>T = 2</var>, <var>S_1 = 1 + 2 = 3</var> and <var>S_2 = 3</var>, with the absolute difference of <var>0</var>.

Sample Input 2

4
1 3 1 1

Sample Output 2

2

If <var>T = 2</var>, <var>S_1 = 1 + 3 = 4</var> and <var>S_2 = 1 + 1 = 2</var>, with the absolute difference of <var>2</var>. We cannot have a smaller absolute difference.

Sample Input 3

8
27 23 76 2 3 5 62 52

Sample Output 3

2


Score : <var>200</var> points

Problem Statement

You are given string <var>S</var> and <var>T</var> consisting of lowercase English letters.

Determine if <var>S</var> equals <var>T</var> after rotation.

That is, determine if <var>S</var> equals <var>T</var> after the following operation is performed some number of times:

Operation: Let <var>S = S_1 S_2 ... S_{|S|}</var>. Change <var>S</var> to <var>S_{|S|} S_1 S_2 ... S_{|S|-1}</var>.

Here, <var>|X|</var> denotes the length of the string <var>X</var>.

Constraints

<var>2 \leq |S| \leq 100</var>

<var>|S| = |T|</var>

<var>S</var> and <var>T</var> consist of lowercase English letters.

Input

Input is given from Standard Input in the following format:

<var>S</var>
<var>T</var>

Output

If <var>S</var> equals <var>T</var> after rotation, print Yes; if it does not, print No.

Sample Input 1

kyoto
tokyo

Sample Output 1

Yes

In the first operation, kyoto becomes okyot.

In the second operation, okyot becomes tokyo.

Sample Input 2

abc
arc

Sample Output 2

No

abc does not equal arc after any number of operations.

Sample Input 3

aaaaaaaaaaaaaaab
aaaaaaaaaaaaaaab

Sample Output 3

Yes


Score : <var>200</var> points

Problem Statement

Find the sum of the integers between <var>1</var> and <var>N</var> (inclusive), whose sum of digits written in base <var>10</var> is between <var>A</var> and <var>B</var> (inclusive).

Constraints

<var>1 \leq N \leq 10^4</var>

<var>1 \leq A \leq B \leq 36</var>

All input values are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>A</var> <var>B</var>

Output

Print the sum of the integers between <var>1</var> and <var>N</var> (inclusive), whose sum of digits written in base <var>10</var> is between <var>A</var> and <var>B</var> (inclusive).

Sample Input 1

20 2 5

Sample Output 1

84

Among the integers not greater than <var>20</var>, the ones whose sums of digits are between <var>2</var> and <var>5</var>, are: <var>2,3,4,5,11,12,13,14</var> and <var>20</var>. We should print the sum of these, <var>84</var>.

Sample Input 2

10 1 2

Sample Output 2

13

Sample Input 3

100 4 16

Sample Output 3

4554


Score : <var>100</var> points

Problem Statement

There are <var>N</var> items, numbered <var>1, 2, \ldots, N</var>.
For each <var>i</var> (<var>1 \leq i \leq N</var>), Item <var>i</var> has a weight of <var>w_i</var> and a value of <var>v_i</var>.

Taro has decided to choose some of the <var>N</var> items and carry them home in a knapsack.
The capacity of the knapsack is <var>W</var>, which means that the sum of the weights of items taken must be at most <var>W</var>.

Find the maximum possible sum of the values of items that Taro takes home.

Constraints

All values in input are integers.

<var>1 \leq N \leq 100</var>

<var>1 \leq W \leq 10^5</var>

<var>1 \leq w_i \leq W</var>

<var>1 \leq v_i \leq 10^9</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>W</var>
<var>w_1</var> <var>v_1</var>
<var>w_2</var> <var>v_2</var>
<var>:</var>
<var>w_N</var> <var>v_N</var>

Output

Print the maximum possible sum of the values of items that Taro takes home.

Sample Input 1

3 8
3 30
4 50
5 60

Sample Output 1

90

Items <var>1</var> and <var>3</var> should be taken.
Then, the sum of the weights is <var>3 + 5 = 8</var>, and the sum of the values is <var>30 + 60 = 90</var>.

Sample Input 2

5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000

Sample Output 2

5000000000

The answer may not fit into a 32-bit integer type.

Sample Input 3

6 15
6 5
5 6
6 4
6 6
3 5
7 2

Sample Output 3

17

Items <var>2, 4</var> and <var>5</var> should be taken.
Then, the sum of the weights is <var>5 + 6 + 3 = 14</var>, and the sum of the values is <var>6 + 6 + 5 = 17</var>.


Score : <var>200</var> points

Problem Statement

Takahashi went to an all-you-can-eat buffet with <var>N</var> kinds of dishes and ate all of them (Dish <var>1</var>, Dish <var>2</var>, <var>\ldots</var>, Dish <var>N</var>) once.

The <var>i</var>-th dish <var>(1 \leq i \leq N)</var> he ate was Dish <var>A_i</var>.

When he eats Dish <var>i</var> <var>(1 \leq i \leq N)</var>, he gains <var>B_i</var> satisfaction points.

Additionally, when he eats Dish <var>i+1</var> just after eating Dish <var>i</var> <var>(1 \leq i \leq N - 1)</var>, he gains <var>C_i</var> more satisfaction points.

Find the sum of the satisfaction points he gained.

Constraints

All values in input are integers.

<var>2 \leq N \leq 20</var>

<var>1 \leq A_i \leq N</var>

<var>A_1, A_2, ..., A_N</var> are all different.

<var>1 \leq B_i \leq 50</var>

<var>1 \leq C_i \leq 50</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var> <var>A_2</var> <var>...</var> <var>A_N</var>
<var>B_1</var> <var>B_2</var> <var>...</var> <var>B_N</var>
<var>C_1</var> <var>C_2</var> <var>...</var> <var>C_{N-1}</var>

Output

Print the sum of the satisfaction points Takahashi gained, as an integer.

Sample Input 1

3
3 1 2
2 5 4
3 6

Sample Output 1

14

Takahashi gained <var>14</var> satisfaction points in total, as follows:

First, he ate Dish <var>3</var> and gained <var>4</var> satisfaction points.

Next, he ate Dish <var>1</var> and gained <var>2</var> satisfaction points.

Lastly, he ate Dish <var>2</var> and gained <var>5 + 3 = 8</var> satisfaction points.

Sample Input 2

4
2 3 4 1
13 5 8 24
45 9 15

Sample Output 2

74

Sample Input 3

2
1 2
50 50
50

Sample Output 3

150


Score : <var>300</var> points

Problem Statement

<var>N</var> tiles are arranged in a row from left to right. The initial color of each tile is represented by a string <var>S</var> of length <var>N</var>.

The <var>i</var>-th tile from the left is painted black if the <var>i</var>-th character of <var>S</var> is 0, and painted white if that character is 1.

You want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.

At least how many tiles need to be repainted to satisfy the condition?

Constraints

<var>1 \leq |S| \leq 10^5</var>

<var>S_i</var> is 0 or 1.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the minimum number of tiles that need to be repainted to satisfy the condition.

Sample Input 1

000

Sample Output 1

1

The condition can be satisfied by repainting the middle tile white.

Sample Input 2

10010010

Sample Output 2

3

Sample Input 3

0

Sample Output 3

0


Score : <var>400</var> points

Problem Statement

Given is a string <var>S</var> consisting of digits from 1 through 9.

Find the number of pairs of integers <var>(i,j)</var> (<var>1 ≤ i ≤ j ≤ |S|</var>) that satisfy the following condition:

Condition: In base ten, the <var>i</var>-th through <var>j</var>-th characters of <var>S</var> form an integer that is a multiple of <var>2019</var>.

Constraints

<var>1 ≤ |S| ≤ 200000</var>

<var>S</var> is a string consisting of digits from 1 through 9.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the number of pairs of integers <var>(i,j)</var> (<var>1 ≤ i ≤ j ≤ |S|</var>) that satisfy the condition.

Sample Input 1

1817181712114

Sample Output 1

3

Three pairs - <var>(1,5)</var>, <var>(5,9)</var>, and <var>(9,13)</var> - satisfy the condition.

Sample Input 2

14282668646

Sample Output 2

2

Sample Input 3

2119

Sample Output 3

0

No pairs satisfy the condition.


Score : <var>300</var> points

Problem Statement

Find the price of a product before tax such that, when the consumption tax rate is <var>8</var> percent and <var>10</var> percent, the amount of consumption tax levied on it is <var>A</var> yen and <var>B</var> yen, respectively. (Yen is the currency of Japan.)

Here, the price before tax must be a positive integer, and the amount of consumption tax is rounded down to the nearest integer.

If multiple prices satisfy the condition, print the lowest such price; if no price satisfies the condition, print -1.

Constraints

<var>1 \leq A \leq B \leq 100</var>

<var>A</var> and <var>B</var> are integers.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var>

Output

If there is a price that satisfies the condition, print an integer representing the lowest such price; otherwise, print -1.

Sample Input 1

2 2

Sample Output 1

25

If the price of a product before tax is <var>25</var> yen, the amount of consumption tax levied on it is:

When the consumption tax rate is <var>8</var> percent: <var>\lfloor 25 \times 0.08 \rfloor = \lfloor 2 \rfloor = 2</var> yen.

When the consumption tax rate is <var>10</var> percent: <var>\lfloor 25 \times 0.1 \rfloor = \lfloor 2.5 \rfloor = 2</var> yen.

Thus, the price of <var>25</var> yen satisfies the condition. There are other possible prices, such as <var>26</var> yen, but print the minimum such price, <var>25</var>.

Sample Input 2

8 10

Sample Output 2

100

If the price of a product before tax is <var>100</var> yen, the amount of consumption tax levied on it is:

When the consumption tax rate is <var>8</var> percent: <var>\lfloor 100 \times 0.08 \rfloor = 8</var> yen.

When the consumption tax rate is <var>10</var> percent: <var>\lfloor 100 \times 0.1 \rfloor = 10</var> yen.

Sample Input 3

19 99

Sample Output 3

-1

There is no price before tax satisfying this condition, so print -1.


Score : <var>300</var> points

Problem Statement

There are <var>3N</var> participants in AtCoder Group Contest.
The strength of the <var>i</var>-th participant is represented by an integer <var>a_i</var>.
They will form <var>N</var> teams, each consisting of three participants.
No participant may belong to multiple teams.

The strength of a team is defined as the second largest strength among its members.
For example, a team of participants of strength <var>1</var>, <var>5</var>, <var>2</var> has a strength <var>2</var>, and a team of three participants of strength <var>3</var>, <var>2</var>, <var>3</var> has a strength <var>3</var>.

Find the maximum possible sum of the strengths of <var>N</var> teams.

Constraints

<var>1 ≤ N ≤ 10^5</var>

<var>1 ≤ a_i ≤ 10^{9}</var>

<var>a_i</var> are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>a_1</var> <var>a_2</var> <var>...</var> <var>a_{3N}</var>

Output

Print the answer.

Sample Input 1

2
5 2 8 5 1 5

Sample Output 1

10

The following is one formation of teams that maximizes the sum of the strengths of teams:

Team <var>1</var>: consists of the first, fourth and fifth participants.

Team <var>2</var>: consists of the second, third and sixth participants.

Sample Input 2

10
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

Sample Output 2

10000000000

The sum of the strengths can be quite large.


Score : <var>200</var> points

Problem Statement

There are <var>N</var> mountains ranging from east to west, and an ocean to the west.

At the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.

The height of the <var>i</var>-th mountain from the west is <var>H_i</var>.

You can certainly see the ocean from the inn at the top of the westmost mountain.

For the inn at the top of the <var>i</var>-th mountain from the west <var>(i = 2, 3, ..., N)</var>, you can see the ocean if and only if <var>H_1 \leq H_i</var>, <var>H_2 \leq H_i</var>, <var>...</var>, and <var>H_{i-1} \leq H_i</var>.

From how many of these <var>N</var> inns can you see the ocean?

Constraints

All values in input are integers.

<var>1 \leq N \leq 20</var>

<var>1 \leq H_i \leq 100</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>H_1</var> <var>H_2</var> <var>...</var> <var>H_N</var>

Output

Print the number of inns from which you can see the ocean.

Sample Input 1

4
6 5 6 8

Sample Output 1

3

You can see the ocean from the first, third and fourth inns from the west.

Sample Input 2

5
4 5 3 5 4

Sample Output 2

3

Sample Input 3

5
9 5 6 8 4

Sample Output 3

1


Score : <var>400</var> points

Problem Statement

We have <var>N+1</var> integers: <var>10^{100}</var>, <var>10^{100}+1</var>, ..., <var>10^{100}+N</var>.

We will choose <var>K</var> or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo <var>(10^9+7)</var>.

Constraints

<var>1 \leq N \leq 2\times 10^5</var>

<var>1 \leq K \leq N+1</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>

Output

Print the number of possible values of the sum, modulo <var>(10^9+7)</var>.

Sample Input 1

3 2

Sample Output 1

10

The sum can take <var>10</var> values, as follows:

<var>(10^{100})+(10^{100}+1)=2\times 10^{100}+1</var>

<var>(10^{100})+(10^{100}+2)=2\times 10^{100}+2</var>

<var>(10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\times 10^{100}+3</var>

<var>(10^{100}+1)+(10^{100}+3)=2\times 10^{100}+4</var>

<var>(10^{100}+2)+(10^{100}+3)=2\times 10^{100}+5</var>

<var>(10^{100})+(10^{100}+1)+(10^{100}+2)=3\times 10^{100}+3</var>

<var>(10^{100})+(10^{100}+1)+(10^{100}+3)=3\times 10^{100}+4</var>

<var>(10^{100})+(10^{100}+2)+(10^{100}+3)=3\times 10^{100}+5</var>

<var>(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\times 10^{100}+6</var>

<var>(10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\times 10^{100}+6</var>

Sample Input 2

200000 200001

Sample Output 2

1

We must choose all of the integers, so the sum can take just <var>1</var> value.

Sample Input 3

141421 35623

Sample Output 3

220280457


Score : <var>400</var> points

Problem Statement

We have a string <var>S</var> of length <var>N</var> consisting of R, G, and B.

Find the number of triples <var>(i,~j,~k)~(1 \leq i < j < k \leq N)</var> that satisfy both of the following conditions:

<var>S_i \neq S_j</var>, <var>S_i \neq S_k</var>, and <var>S_j \neq S_k</var>.

<var>j - i \neq k - j</var>.

Constraints

<var>1 \leq N \leq 4000</var>

<var>S</var> is a string of length <var>N</var> consisting of R, G, and B.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>S</var>

Output

Print the number of triplets in question.

Sample Input 1

4
RRGB

Sample Output 1

1

Only the triplet <var>(1,~3,~4)</var> satisfies both conditions. The triplet <var>(2,~3,~4)</var> satisfies the first condition but not the second, so it does not count.

Sample Input 2

39
RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB

Sample Output 2

1800


Score : <var>200</var> points

Problem Statement

You are given positive integers <var>A</var> and <var>B</var>.

Find the <var>K</var>-th largest positive integer that divides both <var>A</var> and <var>B</var>.

The input guarantees that there exists such a number.

Constraints

All values in input are integers.

<var>1 \leq A, B \leq 100</var>

The <var>K</var>-th largest positive integer that divides both <var>A</var> and <var>B</var> exists.

<var>K \geq 1</var>

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>K</var>

Output

Print the <var>K</var>-th largest positive integer that divides both <var>A</var> and <var>B</var>.

Sample Input 1

8 12 2

Sample Output 1

2

Three positive integers divides both <var>8</var> and <var>12</var>: <var>1, 2</var> and <var>4</var>.
Among them, the second largest is <var>2</var>.

Sample Input 2

100 50 4

Sample Output 2

5

Sample Input 3

1 1 1

Sample Output 3

1


Score : <var>100</var> points

Problem Statement

On the Planet AtCoder, there are four types of bases: A, C, G and T. A bonds with T, and C bonds with G.

You are given a letter <var>b</var> as input, which is A, C, G or T. Write a program that prints the letter representing the base that bonds with the base <var>b</var>.

Constraints

<var>b</var> is one of the letters A, C, G and T.

Input

Input is given from Standard Input in the following format:

<var>b</var>

Output

Print the letter representing the base that bonds with the base <var>b</var>.

Sample Input 1

A

Sample Output 1

T

Sample Input 2

G

Sample Output 2

C


Score : <var>300</var> points

Problem Statement

E869120 found a chest which is likely to contain treasure.

However, the chest is locked. In order to open it, he needs to enter a string <var>S</var> consisting of lowercase English letters.

He also found a string <var>S'</var>, which turns out to be the string <var>S</var> with some of its letters (possibly all or none) replaced with ?.

One more thing he found is a sheet of paper with the following facts written on it:

Condition 1: The string <var>S</var> contains a string <var>T</var> as a contiguous substring.

Condition 2: <var>S</var> is the lexicographically smallest string among the ones that satisfy Condition 1.

Print the string <var>S</var>.

If such a string does not exist, print UNRESTORABLE.

Constraints

<var>1 \leq |S'|, |T| \leq 50</var>

<var>S'</var> consists of lowercase English letters and ?.

<var>T</var> consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

<var>S</var>
<var>T'</var>

Output

Print the string <var>S</var>.

If such a string does not exist, print UNRESTORABLE instead.

Sample Input 1

?tc????
coder

Sample Output 1

atcoder

There are <var>26</var> strings that satisfy Condition 1: atcoder, btcoder, ctcoder,..., ztcoder.
Among them, the lexicographically smallest is atcoder, so we can say <var>S = </var>atcoder.

Sample Input 2

??p??d??
abc

Sample Output 2

UNRESTORABLE

There is no string that satisfies Condition 1, so the string <var>S</var> does not exist.


Score : <var>100</var> points

Problem Statement

Based on some criterion, Snuke divided the integers from <var>1</var> through <var>12</var> into three groups as shown in the figure below.
Given two integers <var>x</var> and <var>y</var> (<var>1 ≤ x < y ≤ 12</var>), determine whether they belong to the same group.

Constraints

<var>x</var> and <var>y</var> are integers.

<var>1 ≤ x < y ≤ 12</var>

Input

Input is given from Standard Input in the following format:

<var>x</var> <var>y</var>

Output

If <var>x</var> and <var>y</var> belong to the same group, print Yes; otherwise, print No.

Sample Input 1

1 3

Sample Output 1

Yes

Sample Input 2

2 4

Sample Output 2

No


Score : <var>300</var> points

Problem Statement

There are <var>N</var> people standing in a row from west to east.
Each person is facing east or west.
The directions of the people is given as a string <var>S</var> of length <var>N</var>.
The <var>i</var>-th person from the west is facing east if <var>S_i =</var> E, and west if <var>S_i =</var> W.

You will appoint one of the <var>N</var> people as the leader, then command the rest of them to face in the direction of the leader.
Here, we do not care which direction the leader is facing.

The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized.
Find the minimum number of people who have to change their directions.

Constraints

<var>2 \leq N \leq 3 \times 10^5</var>

<var>|S| = N</var>

<var>S_i</var> is E or W.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>S</var>

Output

Print the minimum number of people who have to change their directions.

Sample Input 1

5
WEEWW

Sample Output 1

1

Assume that we appoint the third person from the west as the leader.
Then, the first person from the west needs to face east and has to turn around.
The other people do not need to change their directions, so the number of people who have to change their directions is <var>1</var> in this case.
It is not possible to have <var>0</var> people who have to change their directions, so the answer is <var>1</var>.

Sample Input 2

12
WEWEWEEEWWWE

Sample Output 2

4

Sample Input 3

8
WWWWWEEE

Sample Output 3

3


Score : <var>300</var> points

Problem Statement

<var>1000000000000001</var> dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered <var>1</var> through <var>1000000000000001</var>, but he gave them new names, as follows:

the dogs numbered <var>1,2,\cdots,26</var> were respectively given the names a, b, ..., z;

the dogs numbered <var>27,28,29,\cdots,701,702 </var> were respectively given the names aa, ab, ac, ..., zy, zz;

the dogs numbered <var>703,704,705,\cdots,18277,18278 </var> were respectively given the names aaa, aab, aac, ..., zzy, zzz;

the dogs numbered <var>18279,18280,18281,\cdots,475253,475254 </var> were respectively given the names aaaa, aaab, aaac, ..., zzzy, zzzz;

the dogs numbered <var>475255,475256,\cdots </var> were respectively given the names aaaaa, aaaab, ...;

and so on.

To sum it up, the dogs numbered <var>1, 2, \cdots</var> were respectively given the following names:

a, b, ..., z, aa, ab, ..., az, ba, bb, ..., bz, ..., za, zb, ..., zz, aaa, aab, ..., aaz, aba, abb, ..., abz, ..., zzz, aaaa, ...

Now, Roger asks you:

"What is the name for the dog numbered <var>N</var>?"

Constraints

<var>N</var> is an integer.

<var> 1 \leq N \leq 1000000000000001</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the answer to Roger's question as a string consisting of lowercase English letters.

Sample Input 1

2

Sample Output 1

b

Sample Input 2

27

Sample Output 2

aa

Sample Input 3

123456789

Sample Output 3

jjddja


Score : <var>200</var> points

Problem Statement

An integer <var>N</var> is a multiple of <var>9</var> if and only if the sum of the digits in the decimal representation of <var>N</var> is a multiple of <var>9</var>.

Determine whether <var>N</var> is a multiple of <var>9</var>.

Constraints

<var>0 \leq N < 10^{200000}</var>

<var>N</var> is an integer.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

If <var>N</var> is a multiple of <var>9</var>, print Yes; otherwise, print No.

Sample Input 1

123456789

Sample Output 1

Yes

The sum of these digits is <var>1+2+3+4+5+6+7+8+9=45</var>, which is a multiple of <var>9</var>, so <var>123456789</var> is a multiple of <var>9</var>.

Sample Input 2

0

Sample Output 2

Yes

Sample Input 3

31415926535897932384626433832795028841971693993751058209749445923078164062862089986280

Sample Output 3

No


Score : <var>100</var> points

Problem Statement

Shichi-Go-San (literally "Seven-Five-Three") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.

Takahashi is now <var>X</var> years old. Will his growth be celebrated in Shichi-Go-San this time?

Constraints

<var>1 ≤ X ≤ 9</var>

<var>X</var> is an integer.

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

If Takahashi's growth will be celebrated, print YES; if it will not, print NO.

Sample Input 1

5

Sample Output 1

YES

The growth of a five-year-old child will be celebrated.

Sample Input 2

6

Sample Output 2

NO

See you next year.


Score : <var>100</var> points

Problem Statement

Joisino wants to evaluate the formula "<var>A</var> <var>op</var> <var>B</var>".
Here, <var>A</var> and <var>B</var> are integers, and the binary operator <var>op</var> is either + or -.
Your task is to evaluate the formula instead of her.

Constraints

<var>1≦A,B≦10^9</var>

<var>op</var> is either + or -.

Input

The input is given from Standard Input in the following format:

<var>A</var> <var>op</var> <var>B</var>

Output

Evaluate the formula and print the result.

Sample Input 1

1 + 2

Sample Output 1

3

Since <var>1 + 2 = 3</var>, the output should be <var>3</var>.

Sample Input 2

5 - 7

Sample Output 2

-2


Score : <var>100</var> points

Problem Statement

Compute <var>A \times B</var>.

Constraints

<var>1 \leq A \leq 100</var>

<var>1 \leq B \leq 100</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var>

Output

Print the value <var>A \times B</var> as an integer.

Sample Input 1

2 5

Sample Output 1

10

We have <var>2 \times 5 = 10</var>.

Sample Input 2

100 100

Sample Output 2

10000


Score : <var>300</var> points

Problem Statement

Takahashi made <var>N</var> problems for competitive programming.
The problems are numbered <var>1</var> to <var>N</var>, and the difficulty of Problem <var>i</var> is represented as an integer <var>d_i</var> (the higher, the harder).

He is dividing the problems into two categories by choosing an integer <var>K</var>, as follows:

A problem with difficulty <var>K</var> or higher will be for ARCs.

A problem with difficulty lower than <var>K</var> will be for ABCs.

How many choices of the integer <var>K</var> make the number of problems for ARCs and the number of problems for ABCs the same?

Problem Statement

<var>2 \leq N \leq 10^5</var>

<var>N</var> is an even number.

<var>1 \leq d_i \leq 10^5</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>d_1</var> <var>d_2</var> <var>...</var> <var>d_N</var>

Output

Print the number of choices of the integer <var>K</var> that make the number of problems for ARCs and the number of problems for ABCs the same.

Sample Input 1

6
9 1 4 4 6 7

Sample Output 1

2

If we choose <var>K=5</var> or <var>6</var>, Problem <var>1</var>, <var>5</var>, and <var>6</var> will be for ARCs, Problem <var>2</var>, <var>3</var>, and <var>4</var> will be for ABCs, and the objective is achieved.
Thus, the answer is <var>2</var>.

Sample Input 2

8
9 1 14 5 5 4 4 14

Sample Output 2

0

There may be no choice of the integer <var>K</var> that make the number of problems for ARCs and the number of problems for ABCs the same.

Sample Input 3

14
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1

Sample Output 3

42685


Score : <var>100</var> points

Problem Statement

Two deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest.
In this game, an honest player always tells the truth, and an dishonest player always tell lies.
You are given two characters <var>a</var> and <var>b</var> as the input. Each of them is either H or D, and carries the following information:

If <var>a</var>=H, AtCoDeer is honest; if <var>a</var>=D, AtCoDeer is dishonest.
If <var>b</var>=H, AtCoDeer is saying that TopCoDeer is honest; if <var>b</var>=D, AtCoDeer is saying that TopCoDeer is dishonest.

Given this information, determine whether TopCoDeer is honest.

Constraints

<var>a</var>=H or <var>a</var>=D.

<var>b</var>=H or <var>b</var>=D.

Input

The input is given from Standard Input in the following format:

<var>a</var> <var>b</var>

Output

If TopCoDeer is honest, print H. If he is dishonest, print D.

Sample Input 1

H H

Sample Output 1

H

In this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.

Sample Input 2

D H

Sample Output 2

D

In this input, AtCoDeer is dishonest. Hence, contrary to what he says, TopCoDeer is dishonest.

Sample Input 3

D D

Sample Output 3

H


Score : <var>200</var> points

Problem Statement

Given are two strings <var>S</var> and <var>T</var>.

Let us change some of the characters in <var>S</var> so that <var>T</var> will be a substring of <var>S</var>.

At least how many characters do we need to change?

Here, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but not a substring of xxyxx.

Constraints

The lengths of <var>S</var> and <var>T</var> are each at least <var>1</var> and at most <var>1000</var>.

The length of <var>T</var> is at most that of <var>S</var>.

<var>S</var> and <var>T</var> consist of lowercase English letters.

Input

Input is given from Standard Input in the following format:

<var>S</var>
<var>T</var>

Output

Print the minimum number of characters in <var>S</var> that need to be changed.

Sample Input 1

cabacc
abc

Sample Output 1

1

For example, changing the fourth character a in <var>S</var> to c will match the second through fourth characters in <var>S</var> to <var>T</var>.

Since <var>S</var> itself does not have <var>T</var> as its substring, this number of changes - one - is the minimum needed.

Sample Input 2

codeforces
atcoder

Sample Output 2

6


Score : <var>400</var> points

Problem Statement

You are given a permutation <var>p_1,p_2,...,p_N</var> consisting of <var>1</var>,<var>2</var>,..,<var>N</var>.
You can perform the following operation any number of times (possibly zero):

Operation: Swap two adjacent elements in the permutation.

You want to have <var>p_i ≠ i</var> for all <var>1≤i≤N</var>.
Find the minimum required number of operations to achieve this.

Constraints

<var>2≤N≤10^5</var>

<var>p_1,p_2,..,p_N</var> is a permutation of <var>1,2,..,N</var>.

Input

The input is given from Standard Input in the following format:

<var>N</var>
<var>p_1</var> <var>p_2</var> .. <var>p_N</var>

Output

Print the minimum required number of operations

Sample Input 1

5
1 4 3 5 2

Sample Output 1

2

Swap <var>1</var> and <var>4</var>, then swap <var>1</var> and <var>3</var>. <var>p</var> is now <var>4,3,1,5,2</var> and satisfies the condition.
This is the minimum possible number, so the answer is <var>2</var>.

Sample Input 2

2
1 2

Sample Output 2

1

Swapping <var>1</var> and <var>2</var> satisfies the condition.

Sample Input 3

2
2 1

Sample Output 3

0

The condition is already satisfied initially.

Sample Input 4

9
1 2 4 9 5 8 7 3 6

Sample Output 4

3


Score : <var>300</var> points

Problem Statement

You are given a string <var>S</var> of length <var>N</var> consisting of A, C, G and T. Answer the following <var>Q</var> queries:

Query <var>i</var> (<var>1 \leq i \leq Q</var>): You will be given integers <var>l_i</var> and <var>r_i</var> (<var>1 \leq l_i < r_i \leq N</var>). Consider the substring of <var>S</var> starting at index <var>l_i</var> and ending at index <var>r_i</var> (both inclusive). In this string, how many times does AC occurs as a substring?

Notes

A substring of a string <var>T</var> is a string obtained by removing zero or more characters from the beginning and the end of <var>T</var>.

For example, the substrings of ATCODER include TCO, AT, CODER, ATCODER and  (the empty string), but not AC.

Constraints

<var>2 \leq N \leq 10^5</var>

<var>1 \leq Q \leq 10^5</var>

<var>S</var> is a string of length <var>N</var>.

Each character in <var>S</var> is A, C, G or T.

<var>1 \leq l_i < r_i \leq N</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>Q</var>
<var>S</var>
<var>l_1</var> <var>r_1</var>
<var>:</var>
<var>l_Q</var> <var>r_Q</var>

Output

Print <var>Q</var> lines. The <var>i</var>-th line should contain the answer to the <var>i</var>-th query.

Sample Input 1

8 3
ACACTACG
3 7
2 3
1 8

Sample Output 1

2
0
3

Query <var>1</var>: the substring of <var>S</var> starting at index <var>3</var> and ending at index <var>7</var> is ACTAC. In this string, AC occurs twice as a substring.

Query <var>2</var>: the substring of <var>S</var> starting at index <var>2</var> and ending at index <var>3</var> is CA. In this string, AC occurs zero times as a substring.

Query <var>3</var>: the substring of <var>S</var> starting at index <var>1</var> and ending at index <var>8</var> is ACACTACG. In this string, AC occurs three times as a substring.


Score : <var>300</var> points

Problem Statement

Let <var>f(n)</var> be the number of triples of integers <var>(x,y,z)</var> that satisfy both of the following conditions:

<var>1 \leq x,y,z</var>

<var>x^2 + y^2 + z^2 + xy + yz + zx = n</var>

Given an integer <var>N</var>, find each of <var>f(1),f(2),f(3),\ldots,f(N)</var>.

Constraints

All values in input are integers.

<var>1 \leq N \leq 10^4</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print <var>N</var> lines. The <var>i</var>-th line should contain the value <var>f(i)</var>.

Sample Input 1

20

Sample Output 1

0
0
0
0
0
1
0
0
0
0
3
0
0
0
0
0
3
3
0
0

For <var>n=6</var>, only <var>(1,1,1)</var> satisfies both of the conditions. Thus, <var>f(6) = 1</var>.

For <var>n=11</var>, three triples, <var>(1,1,2)</var>, <var>(1,2,1)</var>, and <var>(2,1,1)</var>, satisfy both of the conditions. Thus, <var>f(6) = 3</var>.

For <var>n=17</var>, three triples, <var>(1,2,2)</var>, <var>(2,1,2)</var>, and <var>(2,2,1)</var>, satisfy both of the conditions. Thus, <var>f(17) = 3</var>.

For <var>n=18</var>, three triples, <var>(1,1,3)</var>, <var>(1,3,1)</var>, and <var>(3,1,1)</var>, satisfy both of the conditions. Thus, <var>f(18) = 3</var>.


Score : <var>200</var> points

Problem Statement

You have a digit sequence <var>S</var> of length <var>4</var>. You are wondering which of the following formats <var>S</var> is in:

YYMM format: the last two digits of the year and the two-digit representation of the month (example: 01 for January), concatenated in this order

MMYY format: the two-digit representation of the month and the last two digits of the year, concatenated in this order

If <var>S</var> is valid in only YYMM format, print YYMM; if <var>S</var> is valid in only MMYY format, print MMYY; if <var>S</var> is valid in both formats, print AMBIGUOUS; if <var>S</var> is valid in neither format, print NA.

Constraints

<var>S</var> is a digit sequence of length <var>4</var>.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the specified string: YYMM, MMYY, AMBIGUOUS or NA.

Sample Input 1

1905

Sample Output 1

YYMM

May <var>XX19</var> is a valid date, but <var>19</var> is not valid as a month. Thus, this string is only valid in YYMM format.

Sample Input 2

0112

Sample Output 2

AMBIGUOUS

Both December <var>XX01</var> and January <var>XX12</var> are valid dates. Thus, this string is valid in both formats.

Sample Input 3

1700

Sample Output 3

NA

Neither <var>0</var> nor <var>17</var> is valid as a month. Thus, this string is valid in neither format.


Score : <var>400</var> points

Problem Statement

Mr. Takahashi has a string <var>s</var> consisting of lowercase English letters.
He repeats the following operation on <var>s</var> exactly <var>K</var> times.

Choose an arbitrary letter on <var>s</var> and change that letter to the next alphabet. Note that the next letter of z is a.

For example, if you perform an operation for the second letter on aaz, aaz becomes abz.
If you then perform an operation for the third letter on abz, abz becomes aba.

Mr. Takahashi wants to have the lexicographically smallest string after performing exactly <var>K</var> operations on <var>s</var>.
Find the such string.

Constraints

<var>1≤|s|≤10^5</var>

All letters in <var>s</var> are lowercase English letters.

<var>1≤K≤10^9</var>

Input

The input is given from Standard Input in the following format:

<var>s</var>
<var>K</var>

Output

Print the lexicographically smallest string after performing exactly <var>K</var> operations on <var>s</var>.

Sample Input 1

xyz
4

Sample Output 1

aya

For example, you can perform the following operations: xyz, yyz, zyz, ayz, aya.

Sample Input 2

a
25

Sample Output 2

z

You have to perform exactly <var>K</var> operations.

Sample Input 3

codefestival
100

Sample Output 3

aaaafeaaivap


Score : <var>200</var> points

Problem Statement

Some number of chocolate pieces were prepared for a training camp.
The camp had <var>N</var> participants and lasted for <var>D</var> days.
The <var>i</var>-th participant (<var>1 \leq i \leq N</var>) ate one chocolate piece on each of the following days in the camp: the <var>1</var>-st day, the <var>(A_i + 1)</var>-th day, the <var>(2A_i + 1)</var>-th day, and so on.
As a result, there were <var>X</var> chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces.

Find the number of chocolate pieces prepared at the beginning of the camp.

Constraints

<var>1 \leq N \leq 100</var>

<var>1 \leq D \leq 100</var>

<var>1 \leq X \leq 100</var>

<var>1 \leq A_i \leq 100</var> (<var>1 \leq i \leq N</var>)

All input values are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>D</var> <var>X</var>
<var>A_1</var>
<var>A_2</var>
<var>:</var>
<var>A_N</var>

Output

Find the number of chocolate pieces prepared at the beginning of the camp.

Sample Input 1

3
7 1
2
5
10

Sample Output 1

8

The camp has <var>3</var> participants and lasts for <var>7</var> days.
Each participant eats chocolate pieces as follows:

The first participant eats one chocolate piece on Day <var>1</var>, <var>3</var>, <var>5</var> and <var>7</var>, for a total of four.

The second participant eats one chocolate piece on Day <var>1</var> and <var>6</var>, for a total of two.

The third participant eats one chocolate piece only on Day <var>1</var>, for a total of one.

Since the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is <var>1 + 4 + 2 + 1 = 8</var>.

Sample Input 2

2
8 20
1
10

Sample Output 2

29

Sample Input 3

5
30 44
26
18
81
18
6

Sample Output 3

56


Score : <var>300</var> points

Problem Statement

There are <var>N</var> cubes stacked vertically on a desk.

You are given a string <var>S</var> of length <var>N</var>. The color of the <var>i</var>-th cube from the bottom is red if the <var>i</var>-th character in <var>S</var> is 0, and blue if that character is 1.

You can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.

At most how many cubes can be removed?

Constraints

<var>1 \leq N \leq 10^5</var>

<var>|S| = N</var>

Each character in <var>S</var> is 0 or 1.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the maximum number of cubes that can be removed.

Sample Input 1

0011

Sample Output 1

4

All four cubes can be removed, by performing the operation as follows:

Remove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.

Remove the first and second cubes from the bottom.

Sample Input 2

11011010001011

Sample Output 2

12

Sample Input 3

0

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

In order to pass the entrance examination tomorrow, Taro has to study for <var>T</var> more hours.

Fortunately, he can leap to World B where time passes <var>X</var> times as fast as it does in our world (World A).

While <var>(X \times t)</var> hours pass in World B, <var>t</var> hours pass in World A.

How many hours will pass in World A while Taro studies for <var>T</var> hours in World B?

Constraints

All values in input are integers.

<var>1 \leq T \leq 100</var>

<var>1 \leq X \leq 100</var>

Input

Input is given from Standard Input in the following format:

<var>T</var> <var>X</var>

Output

Print the number of hours that will pass in World A.

The output will be regarded as correct when its absolute or relative error from the judge's output is at most <var>10^{-3}</var>.

Sample Input 1

8 3

Sample Output 1

2.6666666667

While Taro studies for eight hours in World B where time passes three times as fast, <var>2.6666...</var> hours will pass in World A.

Note that an absolute or relative error of at most <var>10^{-3}</var> is allowed.

Sample Input 2

99 1

Sample Output 2

99.0000000000

Sample Input 3

1 100

Sample Output 3

0.0100000000


Score : <var>200</var> points

Problem Statement

You are given a string <var>S</var> consisting of lowercase English letters. Determine whether all the characters in <var>S</var> are different.

Constraints

<var>2 ≤ |S| ≤ 26</var>, where <var>|S|</var> denotes the length of <var>S</var>.

<var>S</var> consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

If all the characters in <var>S</var> are different, print yes (case-sensitive); otherwise, print no.

Sample Input 1

uncopyrightable

Sample Output 1

yes

Sample Input 2

different

Sample Output 2

no

Sample Input 3

no

Sample Output 3

yes


Score : <var>300</var> points

Problem Statement

You are given two non-negative integers <var>L</var> and <var>R</var>.
We will choose two integers <var>i</var> and <var>j</var> such that <var>L \leq i < j \leq R</var>.
Find the minimum possible value of <var>(i \times j) \mbox{ mod } 2019</var>.

Constraints

All values in input are integers.

<var>0 \leq L < R \leq 2 \times 10^9</var>

Input

Input is given from Standard Input in the following format:

<var>L</var> <var>R</var>

Output

Print the minimum possible value of <var>(i \times j) \mbox{ mod } 2019</var> when <var>i</var> and <var>j</var> are chosen under the given condition.

Sample Input 1

2020 2040

Sample Output 1

2

When <var>(i, j) = (2020, 2021)</var>, <var>(i \times j) \mbox{ mod } 2019  = 2</var>.

Sample Input 2

4 5

Sample Output 2

20

We have only one choice: <var>(i, j) = (4, 5)</var>.


Score : <var>300</var> points

Problem Statement

There are <var>N</var> stones arranged in a row. Every stone is painted white or black.
A string <var>S</var> represents the color of the stones. The <var>i</var>-th stone from the left is white if the <var>i</var>-th character of <var>S</var> is ., and the stone is black if the character is #.

Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone.
Find the minimum number of stones that needs to be recolored.

Constraints

<var>1 \leq N \leq 2\times 10^5</var>

<var>S</var> is a string of length <var>N</var> consisting of . and #.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>S</var>

Output

Print the minimum number of stones that needs to be recolored.

Sample Input 1

3
#.#

Sample Output 1

1

It is enough to change the color of the first stone to white.

Sample Input 2

5
#.##.

Sample Output 2

2

Sample Input 3

9
.........

Sample Output 3

0


Score : <var>300</var> points

Problem Statement

Snuke and Raccoon have a heap of <var>N</var> cards. The <var>i</var>-th card from the top has the integer <var>a_i</var> written on it.

They will share these cards.
First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.
Here, both Snuke and Raccoon have to take at least one card.

Let the sum of the integers on Snuke's cards and Raccoon's cards be <var>x</var> and <var>y</var>, respectively.
They would like to minimize <var>|x-y|</var>.
Find the minimum possible value of <var>|x-y|</var>.

Constraints

<var>2 \leq N \leq 2 \times 10^5</var>

<var>-10^{9} \leq a_i \leq 10^{9}</var>

<var>a_i</var> is an integer.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>a_1</var> <var>a_2</var> <var>...</var> <var>a_{N}</var>

Output

Print the answer.

Sample Input 1

6
1 2 3 4 5 6

Sample Output 1

1

If Snuke takes four cards from the top, and Raccoon takes the remaining two cards, <var>x=10</var>, <var>y=11</var>, and thus <var>|x-y|=1</var>. This is the minimum possible value.

Sample Input 2

2
10 -10

Sample Output 2

20

Snuke can only take one card from the top, and Raccoon can only take the remaining one card. In this case, <var>x=10</var>, <var>y=-10</var>, and thus <var>|x-y|=20</var>.


Score : <var>100</var> points

Problem Statement

Serval is fighting with a monster.

The health of the monster is <var>H</var>.

In one attack, Serval can decrease the monster's health by <var>A</var>.
There is no other way to decrease the monster's health.

Serval wins when the monster's health becomes <var>0</var> or below.

Find the number of attacks Serval needs to make before winning.

Constraints

<var>1 \leq H \leq 10^4</var>

<var>1 \leq A \leq 10^4</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>H</var> <var>A</var>

Output

Print the number of attacks Serval needs to make before winning.

Sample Input 1

10 4

Sample Output 1

3

After one attack, the monster's health will be <var>6</var>.

After two attacks, the monster's health will be <var>2</var>.

After three attacks, the monster's health will be <var>-2</var>.

Thus, Serval needs to make three attacks to win.

Sample Input 2

1 10000

Sample Output 2

1

Sample Input 3

10000 1

Sample Output 3

10000


Score : <var>300</var> points

Problem Statement

Given is a sequence of integers <var>A_1, A_2, ..., A_N</var>.
If its elements are pairwise distinct, print YES; otherwise, print NO.

Constraints

<var>2 ≤ N ≤ 200000</var>

<var>1 ≤ A_i ≤ 10^9</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var> <var>...</var> <var>A_N</var>

Output

If the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.

Sample Input 1

5
2 6 1 4 5

Sample Output 1

YES

The elements are pairwise distinct.

Sample Input 2

6
4 1 3 1 6 2

Sample Output 2

NO

The second and fourth elements are identical.

Sample Input 3

2
10000000 10000000

Sample Output 3

NO


Score : <var>200</var> points

Problem Statement

There are <var>N</var> pieces of source code. The characteristics of the <var>i</var>-th code is represented by <var>M</var> integers <var>A_{i1}, A_{i2}, ..., A_{iM}</var>.

Additionally, you are given integers <var>B_1, B_2, ..., B_M</var> and <var>C</var>.

The <var>i</var>-th code correctly solves this problem if and only if <var>A_{i1} B_1 + A_{i2} B_2 + ... + A_{iM} B_M + C > 0</var>.

Among the <var>N</var> codes, find the number of codes that correctly solve this problem.

Constraints

All values in input are integers.

<var>1 \leq N, M \leq 20</var>

<var>-100 \leq A_{ij} \leq 100</var>

<var>-100 \leq B_i \leq 100</var>

<var>-100 \leq C \leq 100</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var> <var>C</var>
<var>B_1</var> <var>B_2</var> <var>...</var> <var>B_M</var>
<var>A_{11}</var> <var>A_{12}</var> <var>...</var> <var>A_{1M}</var>
<var>A_{21}</var> <var>A_{22}</var> <var>...</var> <var>A_{2M}</var>
<var>\vdots</var>
<var>A_{N1}</var> <var>A_{N2}</var> <var>...</var> <var>A_{NM}</var>

Output

Print the number of codes among the given <var>N</var> codes that correctly solve this problem.

Sample Input 1

2 3 -10
1 2 3
3 2 1
1 2 2

Sample Output 1

1

Only the second code correctly solves this problem, as follows:

Since <var>3 \times 1 + 2 \times 2 + 1 \times 3 + (-10) = 0 \leq 0</var>, the first code does not solve this problem.

<var>1 \times 1 + 2 \times 2 + 2 \times 3 + (-10) = 1 > 0</var>, the second code solves this problem.

Sample Input 2

5 2 -4
-2 5
100 41
100 40
-3 0
-6 -2
18 -13

Sample Output 2

2

Sample Input 3

3 3 0
100 -100 0
0 100 100
100 100 100
-100 100 100

Sample Output 3

0

All of them are Wrong Answer. Except yours.


Score : <var>200</var> points

Problem Statement

There is a string <var>S</var> consisting of digits 1, 2, <var>...</var>, 9.
Lunlun, the Dachshund, will take out three consecutive digits from <var>S</var>, treat them as a single integer <var>X</var> and bring it to her master. (She cannot rearrange the digits.)

The master's favorite number is <var>753</var>. The closer to this number, the better.
What is the minimum possible (absolute) difference between <var>X</var> and <var>753</var>?

Constraints

<var>S</var> is a string of length between <var>4</var> and <var>10</var> (inclusive).

Each character in <var>S</var> is 1, 2, <var>...</var>, or 9.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the minimum possible difference between <var>X</var> and <var>753</var>.

Sample Input 1

1234567876

Sample Output 1

34

Taking out the seventh to ninth characters results in <var>X = 787</var>, and the difference between this and <var>753</var> is <var>787 - 753 = 34</var>. The difference cannot be made smaller, no matter where <var>X</var> is taken from.

Note that the digits cannot be rearranged. For example, taking out 567 and rearranging it to 765 is not allowed.

We cannot take out three digits that are not consecutive from <var>S</var>, either. For example, taking out the seventh digit 7, the ninth digit 7 and the tenth digit 6 to obtain 776 is not allowed.

Sample Input 2

35753

Sample Output 2

0

If 753 itself can be taken out, the answer is <var>0</var>.

Sample Input 3

1111111111

Sample Output 3

642

No matter where <var>X</var> is taken from, <var>X = 111</var>, with the difference <var>753 - 111 = 642</var>.


Score : <var>200</var> points

Problem Statement

Given is an integer <var>N</var>. Find the number of positive integers less than or equal to <var>N</var> that have an odd number of digits (in base ten without leading zeros).

Constraints

<var>1 \leq N \leq 10^5</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the number of positive integers less than or equal to <var>N</var> that have an odd number of digits.

Sample Input 1

11

Sample Output 1

9

Among the positive integers less than or equal to <var>11</var>, nine integers have an odd number of digits: <var>1, 2, \ldots, 9</var>.

Sample Input 2

136

Sample Output 2

46

In addition to <var>1, 2, \ldots, 9</var>, another <var>37</var> integers also have an odd number of digits: <var>100, 101, \ldots, 136</var>.

Sample Input 3

100000

Sample Output 3

90909


Score : <var>200</var> points

Problem Statement

Takahashi has a deposit of <var>100</var> yen (the currency of Japan) in AtCoder Bank.

The bank pays an annual interest rate of <var>1</var> % compounded annually. (A fraction of less than one yen is discarded.)

Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach <var>X</var> yen or above for the first time?

Constraints

<var> 101 \le X \le 10^{18} </var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

Print the number of years it takes for Takahashi's balance to reach <var>X</var> yen or above for the first time.

Sample Input 1

103

Sample Output 1

3

The balance after one year is <var>101</var> yen.

The balance after two years is <var>102</var> yen.

The balance after three years is <var>103</var> yen.

Thus, it takes three years for the balance to reach <var>103</var> yen or above.

Sample Input 2

1000000000000000000

Sample Output 2

3760

Sample Input 3

1333333333

Sample Output 3

1706


Score : <var>100</var> points

Problem Statement

Takahashi loves takoyaki - a ball-shaped snack.

With a takoyaki machine, he can make at most <var>X</var> pieces of takoyaki at a time, taking <var>T</var> minutes regardless of the number of pieces to make.

How long does it take to make <var>N</var> takoyaki?

Constraints

<var>1 \leq N,X,T \leq 1000</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>X</var> <var>T</var>

Output

Print an integer representing the minimum number of minutes needed to make <var>N</var> pieces of takoyaki.

Sample Input 1

20 12 6

Sample Output 1

12

He can make <var>12</var> pieces of takoyaki in the first <var>6</var> minutes and <var>8</var> more in the next <var>6</var> minutes, so he can make <var>20</var> in a total of <var>12</var> minutes.

Note that being able to make <var>12</var> in <var>6</var> minutes does not mean he can make <var>2</var> in <var>1</var> minute.

Sample Input 2

1000 1 1000

Sample Output 2

1000000

It seems to take a long time to make this kind of takoyaki.


Score : <var>300</var> points

Problem Statement

A sequence <var>a_1,a_2,... ,a_n</var> is said to be /\/\/\/ when the following conditions are satisfied:

For each <var>i = 1,2,..., n-2</var>, <var>a_i = a_{i+2}</var>.

Exactly two different numbers appear in the sequence.

You are given a sequence <var>v_1,v_2,...,v_n</var> whose length is even.
We would like to make this sequence /\/\/\/ by replacing some of its elements.
Find the minimum number of elements that needs to be replaced.

Constraints

<var>2 \leq n \leq 10^5</var>

<var>n</var> is even.

<var>1 \leq v_i \leq 10^5</var>

<var>v_i</var> is an integer.

Input

Input is given from Standard Input in the following format:

<var>n</var>
<var>v_1</var> <var>v_2</var> <var>...</var> <var>v_n</var>

Output

Print the minimum number of elements that needs to be replaced.

Sample Input 1

4
3 1 3 2

Sample Output 1

1

The sequence <var>3,1,3,2</var> is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it <var>3,1,3,1</var>.

Sample Input 2

6
105 119 105 119 105 119

Sample Output 2

0

The sequence <var>105,119,105,119,105,119</var> is /\/\/\/.

Sample Input 3

4
1 1 1 1

Sample Output 3

2

The elements of the sequence <var>1,1,1,1</var> are all the same, so it is not /\/\/\/.


Score : <var>200</var> points

Problem Statement

There are <var>N</var> apple trees in a row. People say that one of them will bear golden apples.

We want to deploy some number of inspectors so that each of these trees will be inspected.

Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from <var>1</var> through <var>N</var> to the trees. An inspector deployed under the <var>i</var>-th tree <var>(1 \leq i \leq N)</var> will inspect the trees with numbers between <var>i-D</var> and <var>i+D</var> (inclusive).

Find the minimum number of inspectors that we need to deploy to achieve the objective.

Constraints

All values in input are integers.

<var>1 \leq N \leq 20</var>

<var>1 \leq D \leq 20</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>D</var>

Output

Print the minimum number of inspectors that we need to deploy to achieve the objective.

Sample Input 1

6 2

Sample Output 1

2

We can achieve the objective by, for example, placing an inspector under Tree <var>3</var> and Tree <var>4</var>.

Sample Input 2

14 3

Sample Output 2

2

Sample Input 3

20 4

Sample Output 3

3


Score : <var>100</var> points

Problem Statement

How many ways are there to choose two distinct positive integers totaling <var>N</var>, disregarding the order?

Constraints

<var>1 \leq N \leq 10^6</var>

<var>N</var> is an integer.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the answer.

Sample Input 1

4

Sample Output 1

1

There is only one way to choose two distinct integers totaling <var>4</var>: to choose <var>1</var> and <var>3</var>. (Choosing <var>3</var> and <var>1</var> is not considered different from this.)

Sample Input 2

999999

Sample Output 2

499999


Score : <var>200</var> points

Problem Statement

Takahashi and Aoki will have a battle using their monsters.

The health and strength of Takahashi's monster are <var>A</var> and <var>B</var>, respectively, and those of Aoki's monster are <var>C</var> and <var>D</var>, respectively.

The two monsters will take turns attacking, in the order Takahashi's, Aoki's, Takahashi's, Aoki's, ...
Here, an attack decreases the opponent's health by the value equal to the attacker's strength.
The monsters keep attacking until the health of one monster becomes <var>0</var> or below. The person with the monster whose health becomes <var>0</var> or below loses, and the other person wins.

If Takahashi will win, print Yes; if he will lose, print No.

Constraints

<var>1 \leq A,B,C,D \leq 100</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>C</var> <var>D</var>

Output

If Takahashi will win, print Yes; if he will lose, print No.

Sample Input 1

10 9 10 10

Sample Output 1

No

First, Takahashi's monster attacks Aoki's monster, whose health is now <var>10-9=1</var>.

Next, Aoki's monster attacks Takahashi's monster, whose health is now <var>10-10=0</var>.

Takahashi's monster is the first to have <var>0</var> or less health, so Takahashi loses.

Sample Input 2

46 4 40 5

Sample Output 2

Yes


Score : <var>200</var> points

Problem Statement

Takahashi's house has only one socket.

Takahashi wants to extend it with some number of power strips, each with <var>A</var> sockets, into <var>B</var> or more empty sockets.

One power strip with <var>A</var> sockets can extend one empty socket into <var>A</var> empty sockets.

Find the minimum number of power strips required.

Constraints

All values in input are integers.

<var>2 \leq A \leq 20</var>

<var>1 \leq B \leq 20</var>

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var>

Output

Print the minimum number of power strips required.

Sample Input 1

4 10

Sample Output 1

3

<var>3</var> power strips, each with <var>4</var> sockets, extend the socket into <var>10</var> empty sockets.

Sample Input 2

8 9

Sample Output 2

2

<var>2</var> power strips, each with <var>8</var> sockets, extend the socket into <var>15</var> empty sockets.

Sample Input 3

8 8

Sample Output 3

1


Score : <var>200</var> points

Problem Statement

It is November <var>18</var> now in Japan. By the way, <var>11</var> and <var>18</var> are adjacent Lucas numbers.

You are given an integer <var>N</var>. Find the <var>N</var>-th Lucas number.

Here, the <var>i</var>-th Lucas number <var>L_i</var> is defined as follows:

<var>L_0=2</var>

<var>L_1=1</var>

<var>L_i=L_{i-1}+L_{i-2} (i≥2)</var>

Constraints

<var>1≤N≤86</var>

It is guaranteed that the answer is less than <var>10^{18}</var>.

<var>N</var> is an integer.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the <var>N</var>-th Lucas number.

Sample Input 1

5

Sample Output 1

11

<var>L_0=2</var>

<var>L_1=1</var>

<var>L_2=L_0+L_1=3</var>

<var>L_3=L_1+L_2=4</var>

<var>L_4=L_2+L_3=7</var>

<var>L_5=L_3+L_4=11</var>

Thus, the <var>5</var>-th Lucas number is <var>11</var>.

Sample Input 2

86

Sample Output 2

939587134549734843


Score : <var>200</var> points

Problem Statement

There is a grid of squares with <var>H</var> horizontal rows and <var>W</var> vertical columns.
The square at the <var>i</var>-th row from the top and the <var>j</var>-th column from the left is represented as <var>(i, j)</var>.
Each square is black or white.
The color of the square is given as an <var>H</var>-by-<var>W</var> matrix <var>(a_{i, j})</var>.
If <var>a_{i, j}</var> is ., the square <var>(i, j)</var> is white; if <var>a_{i, j}</var> is #, the square <var>(i, j)</var> is black.

Snuke is compressing this grid.
He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:

Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.

It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.
Find the final state of the grid.

Constraints

<var>1 \leq H, W \leq 100</var>

<var>a_{i, j}</var> is . or #.

There is at least one black square in the whole grid.

Input

Input is given from Standard Input in the following format:

<var>H</var> <var>W</var>
<var>a_{1, 1}...a_{1, W}</var>
<var>:</var>
<var>a_{H, 1}...a_{H, W}</var>

Output

Print the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.

Sample Input 1

4 4
##.#
....
##.#
.#.#

Sample Output 1

###
###
.##

The second row and the third column in the original grid will be removed.

Sample Input 2

3 3
#..
.#.
..#

Sample Output 2

#..
.#.
..#

As there is no row or column that consists only of white squares, no operation will be performed.

Sample Input 3

4 5
.....
.....
..#..
.....

Sample Output 3

#

Sample Input 4

7 6
......
....#.
.#....
..#...
..#...
......
.#..#.

Sample Output 4

..#
#..
.#.
.#.
#.#


Score : <var>200</var> points

Problem Statement

Given are <var>1</var>-digit positive integers <var>a</var> and <var>b</var>. Consider these two strings: the concatenation of <var>b</var> copies of the digit <var>a</var>, and the concatenation of <var>a</var> copies of the digit <var>b</var>. Which of these is lexicographically smaller?

Constraints

<var>1 \leq a \leq 9</var>

<var>1 \leq b \leq 9</var>

<var>a</var> and <var>b</var> are integers.

Input

Input is given from Standard Input in the following format:

<var>a</var> <var>b</var>

Output

Print the lexicographically smaller of the two strings. (If the two strings are equal, print one of them.)

Sample Input 1

4 3

Sample Output 1

3333

We have two strings 444 and 3333. Between them, 3333 is the lexicographically smaller.

Sample Input 2

7 7

Sample Output 2

7777777


Score: <var>100</var> points

Problem Statement

Takahashi the Jumbo will practice golf.

His objective is to get a carry distance that is a multiple of <var>K</var>, while he can only make a carry distance of between <var>A</var> and <var>B</var> (inclusive).

If he can achieve the objective, print OK; if he cannot, print NG.

Constraints

All values in input are integers.

<var>1 \leq A \leq B \leq 1000</var>

<var>1 \leq K \leq 1000</var>

Input

Input is given from Standard Input in the following format:

<var>K</var>
<var>A</var> <var>B</var>

Output

If he can achieve the objective, print OK; if he cannot, print NG.

Sample Input 1

7
500 600

Sample Output 1

OK

Among the multiples of <var>7</var>, for example, <var>567</var> lies between <var>500</var> and <var>600</var>.

Sample Input 2

4
5 7

Sample Output 2

NG

No multiple of <var>4</var> lies between <var>5</var> and <var>7</var>.

Sample Input 3

1
11 11

Sample Output 3

OK


Score : <var>100</var> points

Problem Statement

You are given two integers <var>A</var> and <var>B</var> as the input. Output the value of <var>A + B</var>.

However, if <var>A + B</var> is <var>10</var> or greater, output error instead.

Constraints

<var>A</var> and <var>B</var> are integers.

<var>1 ≤ A, B ≤ 9</var>

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var>

Output

If <var>A + B</var> is <var>10</var> or greater, print the string error (case-sensitive); otherwise, print the value of <var>A + B</var>.

Sample Input 1

6 3

Sample Output 1

9

Sample Input 2

6 4

Sample Output 2

error


Score : <var>300</var> points

Problem Statement

Takahashi, Nakahashi and Hikuhashi have integers <var>A</var>, <var>B</var> and <var>C</var>, respectively.
After repeating the following operation <var>K</var> times, find the integer Takahashi will get minus the integer Nakahashi will get:

Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.

However, if the absolute value of the answer exceeds <var>10^{18}</var>, print Unfair instead.

Constraints

<var>1 \leq A,B,C \leq 10^9</var>

<var>0 \leq K \leq 10^{18}</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>C</var> <var>K</var>

Output

Print the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation <var>K</var> times.
If the absolute value of the answer exceeds <var>10^{18}</var>, print Unfair instead.

Sample Input 1

1 2 3 1

Sample Output 1

1

After one operation, Takahashi, Nakahashi and Hikuhashi have <var>5</var>, <var>4</var> and <var>3</var>, respectively. We should print <var>5-4=1</var>.

Sample Input 2

2 3 2 0

Sample Output 2

-1

Sample Input 3

1000000000 1000000000 1000000000 1000000000000000000

Sample Output 3

0


Score : <var>200</var> points

Problem Statement

We have held a popularity poll for <var>N</var> items on sale. Item <var>i</var> received <var>A_i</var> votes.

From these <var>N</var> items, we will select <var>M</var> as popular items. However, we cannot select an item with less than <var>\dfrac{1}{4M}</var> of the total number of votes.

If <var>M</var> popular items can be selected, print Yes; otherwise, print No.

Constraints

<var>1 \leq M \leq N \leq 100</var>

<var>1 \leq A_i \leq 1000</var>

<var>A_i</var> are distinct.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>A_1</var> <var>...</var> <var>A_N</var>

Output

If <var>M</var> popular items can be selected, print Yes; otherwise, print No.

Sample Input 1

4 1
5 4 2 1

Sample Output 1

Yes

There were <var>12</var> votes in total. The most popular item received <var>5</var> votes, and we can select it.

Sample Input 2

3 2
380 19 1

Sample Output 2

No

There were <var>400</var> votes in total. The second and third most popular items received less than <var>\dfrac{1}{4\times 2}</var> of the total number of votes, so we cannot select them. Thus, we cannot select two popular items.

Sample Input 3

12 3
4 56 78 901 2 345 67 890 123 45 6 789

Sample Output 3

Yes


Score : <var>100</var> points

Problem Statement

Snuke has <var>N</var> integers: <var>1,2,\ldots,N</var>.
He will choose <var>K</var> of them and give those to Takahashi.

How many ways are there to choose <var>K</var> consecutive integers?

Constraints

All values in input are integers.

<var>1 \leq K \leq N \leq 50</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>

Output

Print the answer.

Sample Input 1

3 2

Sample Output 1

2

There are two ways to choose two consecutive integers: <var>(1,2)</var> and <var>(2,3)</var>.

Sample Input 2

13 3

Sample Output 2

11


Score : <var>200</var> points

Problem Statement

Takahashi is practicing shiritori alone again today.

Shiritori is a game as follows:

In the first turn, a player announces any one word.

In the subsequent turns, a player announces a word that satisfies the following conditions:

That word is not announced before.

The first character of that word is the same as the last character of the last word announced.

In this game, he is practicing to announce as many words as possible in ten seconds.

You are given the number of words Takahashi announced, <var>N</var>, and the <var>i</var>-th word he announced, <var>W_i</var>, for each <var>i</var>. Determine if the rules of shiritori was observed, that is, every word announced by him satisfied the conditions.

Constraints

<var>N</var> is an integer satisfying <var>2 \leq N \leq 100</var>.

<var>W_i</var> is a string of length between <var>1</var> and <var>10</var> (inclusive) consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>W_1</var>
<var>W_2</var>
<var>:</var>
<var>W_N</var>

Output

If every word announced by Takahashi satisfied the conditions, print Yes; otherwise, print No.

Sample Input 1

4
hoge
english
hoge
enigma

Sample Output 1

No

As hoge is announced multiple times, the rules of shiritori was not observed.

Sample Input 2

9
basic
c
cpp
php
python
nadesico
ocaml
lua
assembly

Sample Output 2

Yes

Sample Input 3

8
a
aa
aaa
aaaa
aaaaa
aaaaaa
aaa
aaaaaaa

Sample Output 3

No

Sample Input 4

3
abc
arc
agc

Sample Output 4

No


Score : <var>300</var> points

Problem Statement

You are given a string <var>S</var> consisting of digits between 1 and 9, inclusive.
You can insert the letter + into some of the positions (possibly none) between two letters in this string.
Here, + must not occur consecutively after insertion.

All strings that can be obtained in this way can be evaluated as formulas.

Evaluate all possible formulas, and print the sum of the results.

Constraints

<var>1 \leq |S| \leq 10</var>

All letters in <var>S</var> are digits between 1 and 9, inclusive.

Input

The input is given from Standard Input in the following format:

<var>S</var>

Output

Print the sum of the evaluated value over all possible formulas.

Sample Input 1

125

Sample Output 1

176

There are <var>4</var> formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,

<var>125</var>

<var>1+25=26</var>

<var>12+5=17</var>

<var>1+2+5=8</var>

Thus, the sum is <var>125+26+17+8=176</var>.

Sample Input 2

9999999999

Sample Output 2

12656242944


Score: <var>100</var> points

Problem Statement

In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.

For example, May <var>3</var>, <var>2018</var> is written as <var>2018</var>-<var>5</var>-<var>3</var>, or <var>5</var>-<var>3</var> without the year.

In this country, a date is called Takahashi when the month and the day are equal as numbers. For example, <var>5</var>-<var>5</var> is Takahashi.

How many days from <var>2018</var>-<var>1</var>-<var>1</var> through <var>2018</var>-<var>a</var>-<var>b</var> are Takahashi?

Constraints

<var>a</var> is an integer between <var>1</var> and <var>12</var> (inclusive).

<var>b</var> is an integer between <var>1</var> and <var>31</var> (inclusive).

<var>2018</var>-<var>a</var>-<var>b</var> is a valid date in Gregorian calendar.

Input

Input is given from Standard Input in the following format:

<var>a</var> <var>b</var>

Output

Print the number of days from <var>2018</var>-<var>1</var>-<var>1</var> through <var>2018</var>-<var>a</var>-<var>b</var> that are Takahashi.

Sample Input 1

5 5

Sample Output 1

5

There are five days that are Takahashi: <var>1</var>-<var>1</var>, <var>2</var>-<var>2</var>, <var>3</var>-<var>3</var>, <var>4</var>-<var>4</var> and <var>5</var>-<var>5</var>.

Sample Input 2

2 1

Sample Output 2

1

There is only one day that is Takahashi: <var>1</var>-<var>1</var>.

Sample Input 3

11 30

Sample Output 3

11

There are eleven days that are Takahashi: <var>1</var>-<var>1</var>, <var>2</var>-<var>2</var>, <var>3</var>-<var>3</var>, <var>4</var>-<var>4</var>, <var>5</var>-<var>5</var>, <var>6</var>-<var>6</var>, <var>7</var>-<var>7</var>, <var>8</var>-<var>8</var>, <var>9</var>-<var>9</var>, <var>10</var>-<var>10</var> and <var>11</var>-<var>11</var>.