#include <bits/stdc++.h>
using namespace std;
const long long maxn = 200005;
vector<long long> adj[maxn];
map<long long, long long> dp1[maxn];
long long nodes(long long u, long long par) {
  if (dp1[u].find(par) != dp1[u].end()) return dp1[u][par];
  long long res = 1;
  for (long long v : adj[u]) {
    if (v == par) continue;
    res += nodes(v, u);
  }
  dp1[u][par] = res;
  return res;
}
map<long long, long long> dp2[maxn];
long long recur(long long u, long long par) {
  if (dp2[u].find(par) != dp2[u].end()) return dp2[u][par];
  long long res = nodes(u, par);
  for (long long v : adj[u]) {
    if (v == par) continue;
    res += recur(v, u);
  }
  dp2[u][par] = res;
  return res;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  long long res = 0;
  bool marked[maxn];
  for (long long i = 0; i < maxn; i++) marked[i] = false;
  for (long long i = 1; i <= n; i++)
    if (adj[i].size() == 1)
      if (!marked[adj[i][0]]) {
        marked[adj[i][0]] = true;
        res = max(res, recur(i, -1));
      }
  cout << res << endl;
}
