#K38877. Taco String Minimal Moves

    ID: 26296 Type: Default 1000ms 256MiB

Taco String Minimal Moves

Taco String Minimal Moves

You are given a string t of length \(n\) and an integer \(m\) representing the maximum jump length. Starting at the first character (index 0) of the string, you can jump to any position \(i\) that satisfies \(max(0, current-m) \leq i \leq min(n-1, current+m)\), where current is your current index. The goal is to reach the last character (index \(n-1\)) in the minimal number of moves. If the starting index is already the last character, the answer is 0.

Note: Moves can go both left and right, but you cannot jump outside the string boundaries.

The problem requires you to compute the minimum number of moves to recover the last character and output that integer.

inputFormat

The input is given from standard input (stdin) and consists of two lines:

  • The first line contains two space-separated integers \(n\) and \(m\), where \(n\) is the length of the string and \(m\) is the maximum jump length.
  • The second line contains the string \(t\) of length \(n\).

outputFormat

Output to standard output (stdout) a single integer representing the minimal number of moves required to reach the last character of the string.

## sample
10 2
abcdefghij
5