Task: Program Execution
Input (English): N, Z, 5159, 8729, S, 8991, 2541
Output (English): 3