#C1552. Minimum Colors Required

    ID: 44770 Type: Default 1000ms 256MiB

Minimum Colors Required

Minimum Colors Required

You are given two integers n and d and asked to determine the minimum number of different colors needed to form a sequence of length n such that for any two adjacent colors in the sequence, the absolute difference between their values is no greater than d. One valid sequence that satisfies the constraints is the sequence 1, 2, 3, \ldots, n since the difference between any two consecutive elements is 1, which is always less than or equal to d when d \ge 1.

Note: Although other sequences might exist with fewer distinct colors under different conditions, the constraints guarantee that the simplest solution is to use n different colors, making the answer equal to n for all valid inputs.

For example:

  • If n = 3 and d = 1, one possible sequence is [1, 2, 3] and hence the answer is 3.
  • If n = 5 and d = 2, a valid sequence is [1, 2, 3, 4, 5], so the answer is 5.

inputFormat

The input consists of a single line containing two space-separated integers:

  • n (the length of the sequence)
  • d (the maximum allowed difference between adjacent colors)

You can assume that n \ge 1 and d \ge 1.

outputFormat

Output a single integer representing the minimum number of different colors needed in order to form a sequence of length n that satisfies the given constraints.

## sample
3 1
3