Task: Program Execution
Input (English): 4, 4, ['3601', '3997', 'S', '1471']
Output (English): 1741