~N~ guards. There are two types of guards, ones with bulletproof armour and ones with fireproof armour. has two weapons, molotov cocktails and shotguns. Unfortunately, ~M~ pairs of guards are one-way friends with each other, therefore must kill some guards before others. He would like to know the minimum number of times he needs to change weapons while following the order of friendships.has sneaked into an Amestris military base and is waiting for Fuhrer King Bradley's arrival. But first, he must take care of the
Line ~1~: ~N~ and ~M~ (~N, M \le 200\,000~)
Line ~2~: ~N~ integers, either ~0~ or ~1~, representing the type of each guard
Lines ~3 \dots M+2~: 2 integers ~a_i~ and ~b_i~, representing that ~a_i~ must be killed before ~b_i~
It is guaranteed that it will be possible to kill all guards. There may be multiple connections between the same pair.
Print on the first line the minimum number of timesis required to change his weapon.
6 4 0 1 0 1 1 1 0 1 3 2 1 2 2 5