#include <bits/stdc++.h>
using namespace std;
std::string dbgDelim(int &i) { return (i++ == 0 ? "" : ", "); }
template <class T>
std::ostream &operator<<(std::ostream &os, std::vector<T> v);
template <class T>
std::ostream &operator<<(std::ostream &os, std::set<T> v);
template <class T>
std::ostream &operator<<(std::ostream &os, std::queue<T> q);
template <class T>
std::ostream &operator<<(std::ostream &os, std::priority_queue<T> q);
template <class T, class K>
std::ostream &operator<<(std::ostream &os, std::pair<T, K> p);
template <class T, class K>
std::ostream &operator<<(std::ostream &os, std::map<T, K> mp);
template <class T, class K>
std::ostream &operator<<(std::ostream &os, std::unordered_map<T, K> mp);
template <int INDEX, class TUPLE>
void dbgDeploy(std::ostream &os, TUPLE tuple) {}
template <int INDEX, class TUPLE, class H, class... Ts>
void dbgDeploy(std::ostream &os, TUPLE t) {
  os << (INDEX == 0 ? "" : ", ") << get<INDEX>(t);
  dbgDeploy<INDEX + 1, TUPLE, Ts...>(os, t);
}
template <class T, class K>
void dbgDeploy(std::ostream &os, std::pair<T, K> p, std::string delim) {
  os << "(" << p.first << delim << p.second << ")";
}
template <class... Ts>
std::ostream &operator<<(std::ostream &os, std::tuple<Ts...> t) {
  os << "(";
  dbgDeploy<0, std::tuple<Ts...>, Ts...>(os, t);
  os << ")";
  return os;
}
template <class T, class K>
std::ostream &operator<<(std::ostream &os, std::pair<T, K> p) {
  dbgDeploy(os, p, ", ");
  return os;
}
template <class T>
std::ostream &operator<<(std::ostream &os, std::vector<T> v) {
  {
    int i = 0;
    os << "{";
    {
      for (T t : v) {
        os << dbgDelim(i) << t;
      };
    }
    os << "}";
    return os;
  };
}
template <class T>
std::ostream &operator<<(std::ostream &os, std::set<T> s) {
  {
    int i = 0;
    os << "{";
    {
      for (T t : s) {
        os << dbgDelim(i) << t;
      };
    }
    os << "}";
    return os;
  };
}
template <class T>
std::ostream &operator<<(std::ostream &os, std::queue<T> q) {
  {
    int i = 0;
    os << "{";
    {
      for (; q.size(); q.pop()) {
        os << dbgDelim(i) << q.front();
      };
    }
    os << "}";
    return os;
  };
}
template <class T>
std::ostream &operator<<(std::ostream &os, std::priority_queue<T> q) {
  {
    int i = 0;
    os << "{";
    {
      for (; q.size(); q.pop()) {
        os << dbgDelim(i) << q.top();
      };
    }
    os << "}";
    return os;
  };
}
template <class T, class K>
std::ostream &operator<<(std::ostream &os, std::map<T, K> mp) {
  {
    int i = 0;
    os << "{";
    {
      for (auto p : mp) {
        os << dbgDelim(i);
        dbgDeploy(os, p, "->");
      };
    }
    os << "}";
    return os;
  };
}
template <class T, class K>
std::ostream &operator<<(std::ostream &os, std::unordered_map<T, K> mp) {
  {
    int i = 0;
    os << "{";
    {
      for (auto p : mp) {
        os << dbgDelim(i);
        dbgDeploy(os, p, "->");
      };
    }
    os << "}";
    return os;
  };
}
const int64_t MAX = 100500;
vector<int64_t> edges[MAX];
int64_t heights[MAX];
int64_t init(int64_t pos = 0, int64_t parent = -1) {
  int64_t height = 0;
  for (auto child : edges[pos])
    if (child != parent) height = max(height, init(child, pos));
  heights[pos] = height + 1;
  return heights[pos];
}
int64_t recur(int64_t pos = 0, int64_t parent = -1, int64_t upper = 0) {
  int64_t ans = 0;
  vector<int64_t> branches({0, upper});
  for (auto child : edges[pos])
    if (child != parent) branches.push_back(heights[child]);
  sort((branches).begin(), (branches).end());
  reverse((branches).begin(), (branches).end());
  for (auto child : edges[pos])
    if (child != parent) {
      ans += recur(child, pos,
                   branches[branches[0] == heights[child] ? 1 : 0] + 1);
    }
  if (pos != 0) {
    ans += min(branches[1] + 1, branches[0] - 1) + 1;
  } else {
    ans += branches[0];
  }
  return ans;
}
int main() {
  int64_t n;
  cin >> n;
  for (int64_t i = 0; i < ((int64_t)(n - 1)); ++i) {
    int64_t a, b;
    cin >> a >> b;
    edges[a - 1].push_back(b - 1);
    edges[b - 1].push_back(a - 1);
  }
  string s;
  cin >> s;
  if (count((s).begin(), (s).end(), '0')) return 0;
  init();
  cout << recur() + 1 << endl;
}
