C. Cycles
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
5 2
3 5 2 4 1
2 3
1 4
Output
3
2