Task: Program Execution
Input (English): 3, 3, ['S', 'D', '785', 'K']
Output (English): 587