Task: Program Execution
Input (English): b, q, 8445, 8307, 1743
Output (English): 18495