In the Byte Mountains there is a ski resort called Bytegary, famous for its cross-country ski tracks. Every track and every lift starts at one clearing and ends at another.
Byteoni is currently at clearing b with s points left on his last card. He wants to get down to one of the base clearings at the foot of Bytegary (those numbered 1 through n′), leaving as few points on the card as possible.
He may ride any track for free, and may ride a lift only when his current number of points is at least that lift's cost. You may assume it is always possible for him to reach a base clearing (he never gets stranded for lack of points).
Compute the smallest number of points that can be left on Byteoni's card when he reaches a base clearing.
Output a single integer: the smallest number of points that can be left on the card when Byteoni reaches a base clearing.