PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000307. Bội của 17 (Multiple of 17)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Bội của 17 (Multiple of 17)

Multiple of 17

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

For an integer n≥10n\ge10, remove its last decimal digit dd and subtract 5d5d from the remaining integer. The result is divisible by 1717 if and only if nn itself is divisible by 1717.

For example, the transformation sends 3434 to 3−5⋅4=−173-5\cdot4=-17, which is divisible by 1717, while it sends 201201 to 20−5⋅1=1520-5\cdot1=15, which is not.

Given a positive integer nn that can be as large as 1010010^{100}, determine whether it is divisible by 1717. The number may exceed the range of ordinary integer types.

Input

One line contains the positive decimal integer nn, without leading zeros.

Output

Print 1 if nn is divisible by 1717, otherwise print 0.

Subtasks

  • Subtask 1 (20 points): 1≤n≤1061\le n\le10^6; nn is written in decimal without leading zeros.
  • Subtask 2 (30 points): 1≤n≤10301\le n\le10^{30}; nn is written in decimal without leading zeros.
  • Subtask 3 (50 points): 1≤n≤101001\le n\le10^{100}; nn is written in decimal without leading zeros.

Examples

Example 1

Input

34

Output

1

Explanation

Removing 44 from 3434 leaves 33. Since 3−5⋅4=−173-5\cdot4=-17 is divisible by 1717, print 1.

Example 2

Input

201

Output

0

Explanation

Removing 11 from 201201 leaves 2020. Since 20−5⋅1=1520-5\cdot1=15 is not divisible by 1717, print 0.

Example 3

Input

2098765413

Output

1

Explanation

Since 2098765413=17⋅1234567892098765413=17\cdot123456789, the given number is divisible by 1717, so the answer is 1.

Example 4

Input

1717171717171717171717171717171717171717171717171718

Output

0

Explanation

The number consists of 25 repetitions of 17, followed by 18. The first 50 digits form a multiple of 1717. Appending 18 gives remainder 18 mod 17=118\bmod17=1, so the answer is 0.