Klee and Bomb
题号:NC232090
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Klee is developing a new type of bomb called Peng Peng Bomb!
There are n bombs numbered from 1 to n, bomb i has color c_i. The n bombs are connected with m links, each link connects two different bombs. Bomb x will explode if meets one of the following conditions:
  • x is on fire by Klee.
  • Bomb y connected to x and of the same color as x explodes. Formally, there exists a link between x and y, and holds.
Klee can choose exact 1 bomb to be on fire. You can change at most 1 bomb x and recolor it (i.e. change c_x to any color you want).
Please help Klee find the maximum number of bombs can be exploded.


输入描述:

The first line of input contains two integers  and  --- the number of bombs and links respectively.
The second line contains n integers --- the color of each bomb.
In the next m lines, each line contains two integers --- two bombs which is connected by the link.
It is guaranteed that for any pair of bombs (x, y), there are at most 1 link between them.

输出描述:

You should output an integer --- the maximum number of bombs can be exploded.
示例1

输入

复制
5 3
1 1 2 1 2
1 2
2 3
3 4

输出

复制
4

说明

In the example 1, if you change c_3 to 1 and Klee choose any one of [1,2,3,4] to be on fire, 4 bombs will explode.
示例2

输入

复制
4 6
1 2 1 2
1 2
2 3
3 4
4 1
1 3
2 4

输出

复制
3