Task: Program Execution
Input (English): 8747, N, M, 4213, W, 3917, k
Output (English): 16877