#### Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

## Problem Description

Gug likes palindromes, so he built an AI to tell if a number is a palindrome. When given a number N, she will say "N is almost a palindrome. It is only X away from the nearest palindrome."

Help Gug's AI find X, the distance to the nearest palindrome

A palindrome is a number that reads the same backward as forward, for example, 1234321, 0 and 10001 are palindromes, but 1112, 100, and 123211 is not. Numbers with leading 0s like 010 are not allowed.

The distance between 2 numbers a and b is defined as |a-b|.

## Input

The input will consist of one line, the number N as defined above.

## Output

The output should contain one line with the integer X as defined above.

## Limits

Subtask 1(1%): 0 < N < 10

Subtask 2(17%): 0 < N < 10^{6}

Subtask 3(29%): 0 < N < 10^{12}

Subtask 4(53%): 0 < N < 10^{18}

Subtask 5(0%): Sample

## Sample Input 1

12

## Sample Output 1

1

## Explanation

12 is 1 away from 11, a palindrome.## Sample Input 2

19

## Sample Output 2

3

## Explanation

19 is 3 away from 22, a palindrome.### Tags

### Subtasks and Limits

Subtask | Score | #TC | Time | Memory | Scoring |
---|---|---|---|---|---|

1 | 1 | 9 | 1s | 256MB | Minimum |

2 | 17 | 12 | 1s | 256MB | Minimum |

3 | 29 | 13 | 1s | 256MB | Minimum |

4 | 53 | 13 | 1s | 256MB | Minimum |

5 | 0 | 2 | 1s | 256MB | Minimum |

### Judge Compile Command

g++-7 ans.cpp -o drunkpalindrome -Wall -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512