You are given a tree T. Choose one internal vertex (a vertex that is not a leaf) to be the root.
Some vertices may be labelled either "black" or "white" — leaves and the root may be labelled as well. For every leaf w, the simple path from the root to w must contain at least one labelled vertex, and the colour of w is defined by the label of the last labelled vertex on that path (the labelled vertex closest to w).
You are given an unrooted tree (no root is fixed) whose leaves are already coloured. You may choose any internal vertex of the tree as its root. Find the minimum number of labels needed to reproduce the given leaf colours in the manner described above.
The first line contains two integers m and n (2≤n<m≤10000), where m is the number of vertices of T and n is the number of leaves. The vertices are numbered 1,2,…,m, and the numbers 1,2,…,n are assigned to the leaves.
Each of the next n lines contains a single number, 0 or 1, describing the colour of a leaf (0 for black, 1 for white). The i-th of these lines describes the colour of leaf i.
Each of the following m−1 lines contains two integers a and b (1≤a<b≤m) separated by a single space, describing one edge of T.
Print a single integer — the minimum number of labels needed to define the colours of the leaves in the way described in the input.