Task: Program Execution
Input (English): K, m, 41, 9039, N, 8905, 4851
Output (English): 22836