There are n students in a class numbered from 0 to n - 1. The teacher will give each student a problem starting with student number 0, then student number 1, and so on until reaching student number n - 1. After that, the teacher will restart the process, starting with student number 0 again.
You are given a 0-indexed integer array chalk and an integer k. There are initially k pieces of chalk. When student number i is given a problem to solve, they will use chalk[i] pieces of chalk to solve that problem. However, if the current number of chalk pieces is strictly less than chalk[i], then student number i will be asked to replace the chalk.
Return the index of the student that will replace the chalk pieces.
Input & Output
Constraints
- n == chalk.length
- 1 ≤ n ≤ 105
- 1 ≤ chalk[i] ≤ 105
- 1 ≤ k ≤ 109