eolymp
bolt
Try our new interface for solving problems
Problems

I Would Walk 500 Miles

I Would Walk 500 Miles

Farmer John wants to divide his n cows, conveniently numbered 1..n, into k non-empty groups such that no two cows from two different groups can interact with each other without walking some number of miles. Cow x and Cow y (where 1x < yn) are willing to walk (2019201913x + 2019201949y) mod 2019201997 miles to see each other.

Given a division of the n cows into k non-empty groups, let m be the minimum of the number of miles any two cows in two different groups are willing to walk to see each other. To test the cows' devotion to each other, Farmer John wants to optimally divide the n cows into k groups such that m is as large as possible.

Input

One line, containing n (n7500) and k (2kn).

Output

Print out m in an optimal solution.

Example

In this example, Cow 1 and Cow 2 are willing to walk 2019201817 miles to see each other. Cow 2 and Cow 3 are willing to walk 2019201685 miles. And Cow 1 and Cow 3 are willing to walk 2019201769 miles. Thus, by grouping the cows such that 1 is by herself and 2 and 3 are grouped together, m = min(2019201817, 2019201769) = 2019201769 (which is the best we can do here).

Time limit 1 second
Memory limit 128 MiB
Input example #1
3 2
Output example #1
2019201769
Source 2019 USACO US Open, Gold