// LNU_Algotesters
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = 2*INF * (LL) INF;

const int MAX = 200 * 1000 + 47;
const int MOD = INF;


VI G[MAX];
char A[MAX];
int S[MAX];
int D[MAX];
LL ans = 0;

void dfs(int v, int p = -1)
{
    S[v] = (A[v] == '1');
    D[v] = 0;
    FOR(i, 0, SZ(G[v]))
    {
        int to = G[v][i];
        if (to == p)continue;
        dfs(to, v);
        S[v] += S[to];
        D[v] = max(D[v], D[to] + 1);
    }
}

void DFS(int v, int p = -1, int x = 0)
{
    int mn = INF;
    int mx = max(x, 0), mx2 = 0;
    
    if (A[v] == '1')mn = 0;
    if (S[0] != S[v])mn = min(x, mn);
    
    FOR(i, 0, SZ(G[v]))
    {
        int to = G[v][i];
        if (to == p)continue;
        
        if (D[to] + 1 > mx)
            mx2 = mx, mx = D[to] + 1;
        else mx2 = max(mx2, D[to] + 1);
        
        if (S[to] != 0)mn = min(mn, D[to] + 1);
    
    }
    
    ans += max(0, min(mx-1, mx2+1) - mn + 1);
    
    FOR(i, 0, SZ(G[v]))
    {
        int to = G[v][i];
        if(to == p)continue;
        if (D[to] + 1 == mx)
            DFS(to, v, mx2 + 1);
        else
            DFS(to, v, mx + 1);
    }
}


int main()
{
    int n;
    scanf("%d", &n);
    FOR(i, 0, n-1)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        --x, --y;
        G[x].PB(y);
        G[y].PB(x);
    }
    scanf("%s", A);
    dfs(0);
    DFS(0);
    ++ans;
    printf("%lld\n", ans);
}
