There is a tree with N vertices numbered 1 through N.
The i-th edge connects Vertex x_i and y_i.
Each vertex is painted white or black.
The initial color of Vertex i is represented by a letter c_i.
c_i = W represents the vertex is white; c_i = B represents the vertex is black.
A cat will walk along this tree.
More specifically, she performs one of the following in one second repeatedly:
 - Choose a vertex that is adjacent to the vertex where she is currently, and move to that vertex. Then, invert the color of the destination vertex.
 - Invert the color of the vertex where she is currently.
The cat's objective is to paint all the vertices black. She may start and end performing actions at any vertex.
At least how many seconds does it takes for the cat to achieve her objective?

-----Constraints-----
 - 1 ≤ N ≤ 10^5
 - 1 ≤ x_i,y_i ≤ N (1 ≤ i ≤ N-1)
 - The given graph is a tree.
 - c_i = W or c_i = B.

-----Input-----
Input is given from Standard Input in the following format:
N
x_1 y_1
x_2 y_2
:
x_{N-1} y_{N-1}
c_1c_2..c_N

-----Output-----
Print the minimum number of seconds required to achieve the objective.

-----Sample Input-----
5
1 2
2 3
2 4
4 5
WBBWW

-----Sample Output-----
5

The objective can be achieved in five seconds, for example, as follows:
 - Start at Vertex 1. Change the color of Vertex 1 to black.
 - Move to Vertex 2, then change the color of Vertex 2 to white.
 - Change the color of Vertex 2 to black.
 - Move to Vertex 4, then change the color of Vertex 4 to black.
 - Move to Vertex 5, then change the color of Vertex 5 to black.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = '\n"""\n\nhttps://atcoder.jp/contests/arc097/tasks/arc097_d\n\n始点と終点関係ある？\n→逆にしても問題はない\n\n黒い葉は完全に無視できる(落とせる)\nよって、葉はすべて白\n葉以外は白黒どっちもあり得る\n\nすべての葉をめぐる最短経路？\nある葉からスタートするのは自明っぽい？\nある白からスタートするのはそう\n\n→自分を塗ってからdfsする\n→全方位木dp?\n\n行きのみで帰らない場所が1つ存在するはず\n→始点と終点のパスとそこから生える木って感じのイメージ\n\n足踏み(停止)の回数を極力少なくしたい\n→始点でも終点でもない場合、 e本の辺がつながってたらe回訪問は確定\n\u3000e^colorが黒でない場合は+1\n→つまり、各頂点で消費する回数は始点・終点でない限り常に一定？\n\n終点はまず葉→始点も葉でおｋ\n始点は足踏みなので1秒つかう\u3000終点も1秒使う\nパス上の点は、e-1回訪問(ここが根本的に違う！)\n\nつまり、あるパスがあって\u3000その長さがL(両端除く)の時、最大でL減る\nただし、パス上にあっても回数が減らない点もある\n\nB=0 W=1とするか\n(color^E) == 1 の点は、E-1回訪問になると足踏みがいらないから2減る\nつまり、そのような点が最大数あるパスを求めればいい\n\n"""\n\nimport sys\nsys.setrecursionlimit(200000)\nfrom collections import deque\n\nMM = 0\n\ndef dfs(v,p):\n    nonlocal MM\n\n    if v != p and linknum[v] == 1:\n        return 0\n\n    cl = []\n    for nex in lis[v]:\n        if nex != p and exist[nex]:\n            tmp = dfs(nex,v)\n            cl.append(tmp)\n    cl.sort()\n    cl.reverse()\n\n    if len(cl) == 1:\n        MM = max(MM , cl[0])\n    else:\n        if (linknum[v]+c[v])%2 == 1:\n            MM = max(MM , cl[0] + cl[1] + 2)\n        else:\n            MM = max(MM , cl[0] + cl[1])\n\n    \n    if (linknum[v]+c[v]) % 2 == 1:\n        return cl[0]+ 2\n    else:\n        return cl[0]\n\nN = int(input())\n\nlis =  [ [] for i in range(N) ]\nlinknum = [0] * N\nfor i in range(N-1):\n    u,v = list(map(int,input().split()))\n    u -= 1\n    v -= 1\n\n    lis[u].append(v)\n    lis[v].append(u)\n    linknum[u] += 1\n    linknum[v] += 1\n\nctmp = input()\nc = []\n\nfor i in ctmp:\n    if i == "B":\n        c.append(0)\n    else:\n        c.append(1)\n\nexist = [True] * N\n\nq = deque([])\nfor i in range(N):\n    if linknum[i] <= 1 and c[i] == 0:\n        q.append(i)\n\nwhile len(q) > 0:\n    now = q.popleft()\n    exist[now] = False\n    linknum[now] = 0\n    \n    for nex in lis[now]:\n        linknum[nex] -= 1\n\n        if linknum[nex] == 1 and c[nex] == 0:\n            q.append(nex)\n\n#print (exist)\nstart = None\nfor i in range(N):\n    if exist[i]:\n        start = i\n        break\nelse:\n    print((0))\n    return\n\nif linknum[start] == 0:\n    print((1))\n    return\n\nans = 0\n#print (linknum)\nfor i in range(N):\n    if exist[i]:\n\n        if (linknum[i] + c[i]) % 2 == 0:\n            ans += linknum[i]\n        else:\n            ans += linknum[i] + 1\n\nMM = 0\npick = dfs(start,start)\nprint((ans - MM))\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: