Under construction

Still being built. Things may change

Power Plant

Time limit1sMemory limit512 MB

Level

Not classified yet

Solved
No attempts yet

Problem

The JOI power plant has NN bases numbered from 1 to NN. The bases are connected by N−1N-1 wires. The ii-th wire (1≤i≤N−11 \le i \le N-1) connects the base AiA_i and the base BiB_i, in both directions. You can travel from any base to any other base by passing through some wires.

Each base has at most one power generator, and each generator has a switch. At the beginning, the switch of every generator is OFF. You are the director of the plant. You may choose some generators and turn their switches ON. Choosing none is allowed. The generators have the following properties.

  • Suppose bases xx, yy, and zz have generators, and you can travel from xx to yy and then from yy to zz without passing through the same wire twice. If the switches of the generators at xx and zz are ON, then the generator at yy is broken.
  • A generator is activated if its switch is ON and it is not broken.

You get 1 yen for each activated generator. You pay 1 yen for each broken generator. Your profit is the total reward minus the total repair expense.

Write a program that, given the bases, the wires, and the generator information, computes the maximum profit.

Input

The first line contains NN. Each of the next N−1N-1 lines contains AiA_i and BiB_i. The last line contains a string SS of length NN.

N
A_1 B_1
...
A_{N-1} B_{N-1}
S

The ii-th character of SS describes base ii. It is 0 if the base has no generator and 1 if it has one.

Output

Write one line to the standard output containing the maximum profit when you choose some generators and turn their switches ON.

Constraints

  • 1≤N≤200 0001 \le N \le 200\,000.
  • SS is a string of length 2N2N consisting of B and W. The character B appears NN times in SS, and the character W appears NN times in SS.

Examples3

  1. Example 1

    Input
    6
    2 3
    4 3
    1 3
    3 5
    6 2
    110011
    
    Expected output
    3
    
  2. Example 2

    Input
    8
    1 2
    3 5
    6 4
    4 5
    5 2
    7 2
    2 8
    11111111
    
    Expected output
    3
    
  3. Example 3

    Input
    16
    7 10
    5 11
    9 4
    14 12
    2 11
    14 16
    4 2
    1 13
    11 3
    7 1
    15 9
    2 1
    11 6
    14 9
    8 9
    0111111001001110
    
    Expected output
    5