Task: Program Execution
Input (English): r, B, 8791, 3165, n, m
Output (English): 11956