#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)(2e5) + 5;
const int INF = (int)(1e9);
vector<int> nxt[maxn];
char s[maxn];
int f[maxn], g[maxn];
int mi[maxn], mx[maxn];
multiset<int> fS[maxn], gS[maxn];
void _dfs(int x, int fa) {
  g[x] = INF;
  for (int i = 0; i < (int)nxt[x].size(); ++i)
    if (nxt[x][i] != fa) {
      _dfs(nxt[x][i], x);
      g[x] = min(g[x], g[nxt[x][i]] + 1);
      f[x] = max(f[x], f[nxt[x][i]] + 1);
      fS[x].insert(f[nxt[x][i]]);
      gS[x].insert(g[nxt[x][i]]);
    }
  if (s[x] == '1') g[x] = min(g[x], f[x]);
}
void dfs(int x, int fa, int v, int w) {
  if (s[x] == '0') mi[x] = min(g[x], w);
  mx[x] = min(max(v, f[x]) - 1, f[x] + 1);
  for (int i = 0; i < (int)nxt[x].size(); ++i)
    if (nxt[x][i] != fa) {
      fS[x].erase(fS[x].find(f[nxt[x][i]]));
      gS[x].erase(gS[x].find(g[nxt[x][i]]));
      int c = max(v, (fS[x].empty() ? -1 : *fS[x].rbegin()) + 1) + 1;
      int d = min(w, (gS[x].empty() ? INF : *gS[x].begin()) + 1) + 1;
      if (s[x] == '1') d = min(d, c);
      dfs(nxt[x][i], x, c, d);
      mx[x] = min(mx[x], c);
      fS[x].insert(f[nxt[x][i]]);
      gS[x].insert(g[nxt[x][i]]);
    }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    nxt[u].push_back(v);
    nxt[v].push_back(u);
  }
  scanf("%s", s + 1);
  _dfs(1, 0);
  dfs(1, 0, 0, INF);
  long long ret = 0;
  for (int i = 1; i <= n; ++i) ret += max(mx[i] - mi[i] + 1, 0);
  return printf("%lld\n", ret + 1), 0;
}
