## Valentine's Day '18 J4 & S1 - Carol's Cute Cactus

View as PDF

Points: 7
Time limit: 2.75s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Carol is buying water for her Cactus. However her Cactus has a problem - he simply does not understand how much water is too much water. However, it is essential that she keep water away from her Cactus, for the Cactus will go seek out more water and then die of water overdose.

Thus, Carol needs a way to calculate the perfect amount of water required to quench her Cactus' thirst.

She gives you , the minimum amount of water Cactus must drink to stay alive, and , the amount of water that will cause water overdose and death. Carol discovered that she can prevent Cactus from seeking out more water by presenting the water at a cute number, thus distracting Cactus.

A cute number is a number that is palindromic. e.g. is cute, and is cute. Find the palindromic number that is farthest from and as possible. This would be the maximum of the smaller of the two absolute differences. If there are multiple cute numbers equally far apart, then use the highest, as more water makes Cactus happy.

#### Input Specification

The first line will contain and , the minimum and maximum water value.

#### Output Specification

The amount of water that Carol should purchase for her Cactus. The input data are set such that Carol will be able to purchase water for her Cactus.

#### Sample Input

1000 5000

#### Sample Output

3003

#### Sample Input

234 2343

#### Sample Output

1331