Task: Program Execution
Input (English): Q, 9857, 507, 9573, q, 4941
Output (English): 2, 3, 4, 6