#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:167772160000")
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <cstdio>
#include <stdlib.h>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <climits>
#include <set>
#include <bitset>
#include <math.h>
#include <queue>
#include <map>
#include <sstream>
#include <functional>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <regex>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<double, double> pdd;
template <typename T> using min_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <typename T> using max_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;

#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define TESTS(t) int NUMBER_OF_TESTS; cin >> NUMBER_OF_TESTS; for(int t = 1; t <= NUMBER_OF_TESTS; t++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ROF(i, start, end) for(int i = (start); i >= (end); i--)
#define all(x) (x).begin(), (x).end()
//#define endl "\n"
#define PI (asin(1)*2)
#define oo 1000000000LL
#define OO 1000000000000000000LL
#define eps 1e-8
#define in(a, b)   ((b).find(a) != (b).end())
#define mp(a, b)   make_pair((a), (b))
#define sgn(a)     ((a) > eps ? 1 : ((a) < -eps ? -1 : 0))
#define cl1(x)     ((x)&((x)-1)) // clear lowest 1 bit
#define cl0(x)     ((x)|((x)+1)) // clear lowest 0 bit
#define ct1(x)     ((x)&((x)+1)) // clear all trailing 1 bits
#define pb push_back
#define MOD 1000000007
#define MAX_N 1000000
using namespace std;

bool visited[MAX_N];
vector<int> adjList[MAX_N];
int sz[MAX_N];
ll cnt[MAX_N];
ll sum1[MAX_N], sum2[MAX_N];
int n;
ll numOdd = 0;

pii dfs(int p, int par = -1) {
    visited[p] = true;
    pii ans = { 0,0 };
    vector<pii> sub;
    for (int i = 0; i < adjList[p].size(); i++)
    {
        int x = adjList[p][i];
        if (visited[x]) continue;
        auto res = dfs(x, p);
        sub.pb(res);
        ans.first += res.first;
        ans.second += res.second;
    }
    numOdd += ans.second;
    for (auto x : sub) {
        auto aa = ans;
        aa.first -= x.first;
        aa.second -= x.second;
        numOdd += aa.first*aa.second;
    }
    swap(ans.first, ans.second);
    ans.second++;
    return ans;
}

/*ll getSum() {
    FOR(i, 0, n) cnt[i] = 1;
    FOR(i, 0, n) visited[i] = false;
    stack<int> leaves;
    FOR(i, 0, n) {
        if (sz[i] == 1) leaves.push(i);
    }
    ll s = 0;
    while (!leaves.empty()) {
        auto t = leaves.top(); leaves.pop();
        visited[t] = true;
        int b = -1;
        for (auto x : adjList[t]) {
            if (!visited[x]) {
                b = x;
                sz[b]--;
                if (sz[b] == 1) leaves.push(b);
                break;
            }
        }
        s += cnt[t] * (n - cnt[t]);
        cnt[b] += cnt[t];
    }
    return s;
}*/
void dfs1(ll node)
{
    visited[node] = 1;
    for (int i = 0; i < adjList[node].size(); i++)
    {
        ll x = adjList[node][i], w = 1;
        if (visited[x]) continue;
        dfs1(x);
        sum1[node] += sum1[x] + cnt[x] * w;
        cnt[node] += cnt[x];
    }
    cnt[node]++;
}
void dfs2(ll node)
{
    if (node == 0)
    {
        sum2[node] = sum1[node];
    }
    visited[node] = 1;
    for (int i = 0; i < adjList[node].size(); i++)
    {
        ll x = adjList[node][i], w = 1;
        if (visited[x]) continue;
        sum2[x] = sum1[x] + sum2[node] - sum1[x] - cnt[x] * w + w * (n - cnt[x]);
        dfs2(x);
    }
}

int main()
{
    FAST_IO
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> n;
    FOR(i, 0, n-1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        adjList[u].pb(v);
        adjList[v].pb(u);
        sz[u]++;
        sz[v]++;
    }
    auto r = dfs(0);
    FOR(i, 0, n) visited[i] = false;
    dfs1(0);
    FOR(i, 0, n) visited[i] = false;
    dfs2(0);
    //ll firstSum = getSum();
    double ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += (double)sum2[i] / 2;
    }
    cout << ((ll)ans + numOdd) / 2;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
typedef long long LL;
vector<int> G[N];
int n,sum[N],odd[N],even[N];
LL sumodd[N],sumeven[N];
LL ans;
void dfs(int u,int fa) {
  sum[u] = 1;
  even[u] = odd[u] = 0;
  for (auto v: G[u]) {
    if (v==fa) continue;
    dfs(v,u);
    sumodd[u] += even[v]*odd[u];
    sumodd[u] += odd[v]*even[u];
    odd[u]++;
    odd[u] += even[v];
    even[u] += odd[v];
    ans += 1LL*(n-sum[v])*sum[v];

    sum[u] += sum[v];
  }
}
int main() {
  scanf("%d",&n);
  for (int i=0,u,v; i<n-1; i++) {
    scanf("%d%d",&u,&v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  ans = 0;
  dfs(1,1);
  for (int i=1; i<=n; i++) {
    //cout << i << ' ' << sumodd[i] << ' ' << odd[i] << endl;
    ans += sumodd[i]+odd[i];
  }
  cout << ans/2 << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
typedef long long LL;
vector<int> G[N];
int n;
LL sum[N],odd[N],even[N];
LL sumodd[N],sumeven[N];
LL ans;
void dfs(int u,int fa) {
  sum[u] = 1;
  even[u] = odd[u] = 0;
  for (auto v: G[u]) {
    if (v==fa) continue;
    dfs(v,u);
    sumodd[u] += even[v]*odd[u];
    sumodd[u] += odd[v]*even[u];
    odd[u]++;
    odd[u] += even[v];
    even[u] += odd[v];
    ans += 1LL*(n-sum[v])*sum[v];

    sum[u] += sum[v];
  }
}
int main() {
  scanf("%d",&n);
  for (int i=0,u,v; i<n-1; i++) {
    scanf("%d%d",&u,&v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  ans = 0;
  dfs(1,1);
  for (int i=1; i<=n; i++) {
    //cout << i << ' ' << sumodd[i] << ' ' << odd[i] << endl;
    ans += sumodd[i]+odd[i];
  }
  cout << ans/2 << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
typedef long long LL;
vector<int> G[N];
int n;
LL sum[N],odd[N],even[N];
LL sumodd[N],sumeven[N];
LL ans;
void dfs(int u,int fa) {
  sum[u] = 1;
  even[u] = odd[u] = 0;
  for (auto v: G[u]) {
    if (v==fa) continue;
    dfs(v,u);
    sumodd[u] += even[v]*even[u];
    sumodd[u] += odd[v]*odd[u];
    sumodd[u] += even[u];
    odd[u]++;
    odd[u] += even[v];
    even[u] += odd[v];
    ans += 1LL*(n-sum[v])*sum[v];

    sum[u] += sum[v];
  }
}
int main() {
  scanf("%d",&n);
  for (int i=0,u,v; i<n-1; i++) {
    scanf("%d%d",&u,&v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  ans = 0;
  dfs(1,1);
  for (int i=1; i<=n; i++) {
  //  cout << i << ' ' << sumodd[i] << ' ' << odd[i] << endl;
    ans += sumodd[i]+odd[i];
  }
  cout << ans/2 << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
typedef long long LL;
vector<int> G[N];
int n;
LL sum[N],odd[N],even[N];
LL sumodd[N],sumeven[N];
LL ans;
void dfs(int u,int fa) {
  sum[u] = 1;
  even[u] = odd[u] = 0;
  for (auto v: G[u]) {
    if (v==fa) continue;
    dfs(v,u);
    sumodd[u] += even[v]*even[u];
    sumodd[u] += odd[v]*odd[u];
    odd[u]++;
    odd[u] += even[v];
    even[u] += odd[v];
    ans += 1LL*(n-sum[v])*sum[v];

    sum[u] += sum[v];
  }
}
int main() {
  scanf("%d",&n);
  for (int i=0,u,v; i<n-1; i++) {
    scanf("%d%d",&u,&v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  ans = 0;
  dfs(1,1);
  for (int i=1; i<=n; i++) {
  //  cout << i << ' ' << sumodd[i] << ' ' << odd[i] << endl;
    ans += sumodd[i]+odd[i];
  }
  cout << ans/2 << endl;
  return 0;
}


#pragma comment(linker, "/STACK:102400000,102400000")
#ifndef ONLINE_JUDGE
#include "stdafx.h"
#else
#include<bits/stdc++.h>
#endif
using namespace std;
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define trav(a,x) for (auto &a:x)
#define mp(a,b) make_pair(a,b)
#define all(x) x.begin(),x.end()
#define fill(x,c) memset(x,c,sizeof(x))
#define write(x) cout<<(x)<<' '
#define writeln(x) cout<<(x)<<endl
#define ADDMOD(x,a,m) x=(((x)+(a)%m)%(m)+m)%m
#define MLTMOD(x,a,m) x=(((x)*((a)%m))%(m)+m)%m
typedef long long lnt;
typedef vector<int> VI;
typedef vector<lnt> VL;
typedef pair<int, int> PII;
typedef pair<lnt, lnt> PLL;
typedef vector<pair<int, int>> VPI;
typedef vector<pair<lnt, lnt>> VPL;
typedef queue<int> QI;
typedef queue<lnt> QL;
typedef map<int, int> MII;
typedef map<lnt, lnt> MLL;
typedef map<pair<int, int>, int> MPI;
typedef map<pair<lnt, lnt>, lnt> MPL;
typedef map<vector<int>, int> MVI;
typedef map<vector<lnt>, lnt> MVL;
typedef set<int> SI;
typedef set<lnt> SL;
typedef set<pair<int, int>> SPI;
typedef set<pair<lnt, lnt>> SPL;

const double eps = 1e-6;
inline lnt pow(lnt a, lnt b, lnt p) {
    lnt rtn = 1;
    while (b) {
        if (b & 1) rtn = rtn * a % p;
        a = a * a % p;
        b >>= 1;
    }
    return rtn;
}
lnt inv(lnt a, lnt p) {
    return pow(a, p - 2, p);
}
long long gcd(long long a, long long b) {
    long long k;
    while (b != 0) {
        k = b;
        b = a % b;
        a = k;
    }
    return a;
}
void makedata() {
    freopen("input.txt", "w", stdout);
    srand((unsigned)time(NULL));
    fclose(stdout);
}

VI G[220000];
int n, fa[220000], dep[220000], cnt[220000], sumd[220000], oddd[220000], eved[220000];
void root(int x, int f, int d) {
    fa[x] = f;
    dep[x] = d;
    cnt[x] = 1;
    eved[x] = 1;
    trav(y, G[x]) {
        if (y == f) continue;
        root(y, x, d + 1);
        cnt[x] += cnt[y];
        sumd[x] += sumd[y] + cnt[y];
        oddd[x] += eved[y];
        eved[x] += oddd[y];
    }
}
lnt dfs(int x) {
    lnt rtn = 0;
    trav(y, G[x]) {
        if (y == fa[x]) continue;
        rtn += (sumd[y] + cnt[y]) * (cnt[x] - 1 - cnt[y]);
    }
    rtn /= 2;
    trav(y, G[x]) {
        if (y == fa[x]) continue;
        rtn += dfs(y);
    }
    rtn += sumd[x];
    return rtn;
}
lnt getodd(int x) {
    lnt rtn = 0;
    trav(y, G[x]) {
        if (y == fa[x]) continue;
        rtn += eved[y] * (eved[x] - 1 - oddd[y]);
        rtn += oddd[y] * (oddd[x] - eved[y]);
    }
    trav(y, G[x]) {
        if (y == fa[x]) continue;
        rtn += getodd(y);
    }
    rtn += oddd[x];
    return rtn;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    //makedata();
    std::ios::sync_with_stdio(0), cin.tie(0);
    int x, y;
    cin >> n;
    rep(i, 1, n - 1) {
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    root(1, 0, 0);
    lnt ans = dfs(1);
    ans = (ans - (n - 1)) / 2;
    ans += getodd(1);
    writeln(ans);
    return 0;
}


#pragma comment(linker, "/STACK:102400000,102400000")
#ifndef ONLINE_JUDGE
#include "stdafx.h"
#else
#include<bits/stdc++.h>
#endif
using namespace std;
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define trav(a,x) for (auto &a:x)
#define mp(a,b) make_pair(a,b)
#define all(x) x.begin(),x.end()
#define fill(x,c) memset(x,c,sizeof(x))
#define write(x) cout<<(x)<<' '
#define writeln(x) cout<<(x)<<endl
#define ADDMOD(x,a,m) x=(((x)+(a)%m)%(m)+m)%m
#define MLTMOD(x,a,m) x=(((x)*((a)%m))%(m)+m)%m
typedef long long lnt;
typedef vector<int> VI;
typedef vector<lnt> VL;
typedef pair<int, int> PII;
typedef pair<lnt, lnt> PLL;
typedef vector<pair<int, int>> VPI;
typedef vector<pair<lnt, lnt>> VPL;
typedef queue<int> QI;
typedef queue<lnt> QL;
typedef map<int, int> MII;
typedef map<lnt, lnt> MLL;
typedef map<pair<int, int>, int> MPI;
typedef map<pair<lnt, lnt>, lnt> MPL;
typedef map<vector<int>, int> MVI;
typedef map<vector<lnt>, lnt> MVL;
typedef set<int> SI;
typedef set<lnt> SL;
typedef set<pair<int, int>> SPI;
typedef set<pair<lnt, lnt>> SPL;

const double eps = 1e-6;
inline lnt pow(lnt a, lnt b, lnt p) {
    lnt rtn = 1;
    while (b) {
        if (b & 1) rtn = rtn * a % p;
        a = a * a % p;
        b >>= 1;
    }
    return rtn;
}
lnt inv(lnt a, lnt p) {
    return pow(a, p - 2, p);
}
long long gcd(long long a, long long b) {
    long long k;
    while (b != 0) {
        k = b;
        b = a % b;
        a = k;
    }
    return a;
}
void makedata() {
    freopen("input.txt", "w", stdout);
    srand((unsigned)time(NULL));
    fclose(stdout);
}

VL G[220000];
lnt n, fa[220000], dep[220000], cnt[220000], sumd[220000], oddd[220000], eved[220000];
void root(int x, int f, int d) {
    fa[x] = f;
    dep[x] = d;
    cnt[x] = 1;
    eved[x] = 1;
    trav(y, G[x]) {
        if (y == f) continue;
        root(y, x, d + 1);
        cnt[x] += cnt[y];
        sumd[x] += sumd[y] + cnt[y];
        oddd[x] += eved[y];
        eved[x] += oddd[y];
    }
}
lnt dfs(int x) {
    lnt rtn = 0;
    trav(y, G[x]) {
        if (y == fa[x]) continue;
        rtn += (sumd[y] + cnt[y]) * (cnt[x] - 1 - cnt[y]);
    }
    trav(y, G[x]) {
        if (y == fa[x]) continue;
        rtn += dfs(y);
    }
    rtn += sumd[x];
    return rtn;
}
lnt getodd(int x) {
    lnt rtn = 0;
    trav(y, G[x]) {
        if (y == fa[x]) continue;
        rtn += eved[y] * (eved[x] - 1 - oddd[y]);
        //rtn += oddd[y] * (oddd[x] - eved[y]);
    }
    trav(y, G[x]) {
        if (y == fa[x]) continue;
        rtn += getodd(y);
    }
    rtn += oddd[x];
    return rtn;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    //makedata();
    std::ios::sync_with_stdio(0), cin.tie(0);
    lnt x, y;
    cin >> n;
    rep(i, 1, n - 1) {
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    root(1, 0, 0);
    lnt tot = dfs(1), odd = getodd(1);
    writeln((tot - odd) / 2 + odd);
    return 0;
}


#pragma comment(linker, "/STACK:102400000,102400000")
#ifndef ONLINE_JUDGE
#include "stdafx.h"
#else
#include<bits/stdc++.h>
#endif
using namespace std;
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define trav(a,x) for (auto &a:x)
#define mp(a,b) make_pair(a,b)
#define all(x) x.begin(),x.end()
#define fill(x,c) memset(x,c,sizeof(x))
#define write(x) cout<<(x)<<' '
#define writeln(x) cout<<(x)<<endl
#define ADDMOD(x,a,m) x=(((x)+(a)%m)%(m)+m)%m
#define MLTMOD(x,a,m) x=(((x)*((a)%m))%(m)+m)%m
typedef long long lnt;
typedef vector<int> VI;
typedef vector<lnt> VL;
typedef pair<int, int> PII;
typedef pair<lnt, lnt> PLL;
typedef vector<pair<int, int>> VPI;
typedef vector<pair<lnt, lnt>> VPL;
typedef queue<int> QI;
typedef queue<lnt> QL;
typedef map<int, int> MII;
typedef map<lnt, lnt> MLL;
typedef map<pair<int, int>, int> MPI;
typedef map<pair<lnt, lnt>, lnt> MPL;
typedef map<vector<int>, int> MVI;
typedef map<vector<lnt>, lnt> MVL;
typedef set<int> SI;
typedef set<lnt> SL;
typedef set<pair<int, int>> SPI;
typedef set<pair<lnt, lnt>> SPL;

const double eps = 1e-6;
inline lnt pow(lnt a, lnt b, lnt p) {
    lnt rtn = 1;
    while (b) {
        if (b & 1) rtn = rtn * a % p;
        a = a * a % p;
        b >>= 1;
    }
    return rtn;
}
lnt inv(lnt a, lnt p) {
    return pow(a, p - 2, p);
}
long long gcd(long long a, long long b) {
    long long k;
    while (b != 0) {
        k = b;
        b = a % b;
        a = k;
    }
    return a;
}
void makedata() {
    freopen("input.txt", "w", stdout);
    srand((unsigned)time(NULL));
    fclose(stdout);
}

VI G[220000];
int n, fa[220000], dep[220000], cnt[220000], sumd[220000], oddd[220000], eved[220000];
void root(int x, int f, int d) {
    fa[x] = f;
    dep[x] = d;
    cnt[x] = 1;
    eved[x] = 1;
    trav(y, G[x]) {
        if (y == f) continue;
        root(y, x, d + 1);
        cnt[x] += cnt[y];
        sumd[x] += sumd[y] + cnt[y];
        oddd[x] += eved[y];
        eved[x] += oddd[y];
    }
}
lnt dfs(int x) {
    lnt rtn = sumd[x];
    trav(y, G[x]) {
        if (y == fa[x]) continue;
        rtn += dfs(y);
        rtn += (sumd[y] + cnt[y]) * (cnt[x] - 1 - cnt[y]);
    }
    return rtn;
}
lnt getodd(int x) {
    lnt rtn = oddd[x];
    trav(y, G[x]) {
        if (y == fa[x]) continue;
        rtn += getodd(y);
        rtn += eved[y] * (eved[x] - 1 - oddd[y]);
        rtn += oddd[y] * (oddd[x] - eved[y]);
    }
    return rtn;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    //makedata();
    std::ios::sync_with_stdio(0), cin.tie(0);
    int x, y;
    cin >> n;
    rep(i, 1, n - 1) {
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    root(1, 0, 0);
    lnt ans = dfs(1);
	ans = (ans - (n - 1)) / 2;
    ans += getodd(1);
    writeln(ans);
    return 0;
}


#pragma comment(linker, "/STACK:102400000,102400000")
#ifndef ONLINE_JUDGE
#include "stdafx.h"
#else
#include<bits/stdc++.h>
#endif
using namespace std;
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define trav(a,x) for (auto &a:x)
#define mp(a,b) make_pair(a,b)
#define all(x) x.begin(),x.end()
#define fill(x,c) memset(x,c,sizeof(x))
#define write(x) cout<<(x)<<' '
#define writeln(x) cout<<(x)<<endl
#define ADDMOD(x,a,m) x=(((x)+(a)%m)%(m)+m)%m
#define MLTMOD(x,a,m) x=(((x)*((a)%m))%(m)+m)%m
typedef long long lnt;
typedef vector<int> VI;
typedef vector<lnt> VL;
typedef pair<int, int> PII;
typedef pair<lnt, lnt> PLL;
typedef vector<pair<int, int>> VPI;
typedef vector<pair<lnt, lnt>> VPL;
typedef queue<int> QI;
typedef queue<lnt> QL;
typedef map<int, int> MII;
typedef map<lnt, lnt> MLL;
typedef map<pair<int, int>, int> MPI;
typedef map<pair<lnt, lnt>, lnt> MPL;
typedef map<vector<int>, int> MVI;
typedef map<vector<lnt>, lnt> MVL;
typedef set<int> SI;
typedef set<lnt> SL;
typedef set<pair<int, int>> SPI;
typedef set<pair<lnt, lnt>> SPL;

const double eps = 1e-6;
inline lnt pow(lnt a, lnt b, lnt p) {
    lnt rtn = 1;
    while (b) {
        if (b & 1) rtn = rtn * a % p;
        a = a * a % p;
        b >>= 1;
    }
    return rtn;
}
lnt inv(lnt a, lnt p) {
    return pow(a, p - 2, p);
}
long long gcd(long long a, long long b) {
    long long k;
    while (b != 0) {
        k = b;
        b = a % b;
        a = k;
    }
    return a;
}
void makedata() {
    freopen("input.txt", "w", stdout);
    srand((unsigned)time(NULL));
    fclose(stdout);
}

VI G[220000];
int n, fa[220000], dep[220000], cnt[220000], sumd[220000], oddd[220000], eved[220000];
void root(int x, int f, int d) {
    fa[x] = f;
    dep[x] = d;
    cnt[x] = 1;
    eved[x] = 1;
    trav(y, G[x]) {
        if (y == f) continue;
        root(y, x, d + 1);
        cnt[x] += cnt[y];
        sumd[x] += sumd[y] + cnt[y];
        oddd[x] += eved[y];
        eved[x] += oddd[y];
    }
}
lnt dfs(int x) {
    lnt rtn = 0;
    trav(y, G[x]) {
        if (y == fa[x]) continue;
        rtn += (sumd[y] + cnt[y]) * (cnt[x] - 1 - cnt[y]);
    }
    trav(y, G[x]) {
        if (y == fa[x]) continue;
        rtn += dfs(y);
    }
    rtn += sumd[x];
    return rtn;
}
lnt getodd(int x) {
    lnt rtn = 0;
    trav(y, G[x]) {
        if (y == fa[x]) continue;
        rtn += eved[y] * (eved[x] - 1 - oddd[y]);
        //rtn += oddd[y] * (oddd[x] - eved[y]);
    }
    trav(y, G[x]) {
        if (y == fa[x]) continue;
        rtn += getodd(y);
    }
    rtn += oddd[x];
    return rtn;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    //makedata();
    std::ios::sync_with_stdio(0), cin.tie(0);
    int x, y;
    cin >> n;
    rep(i, 1, n - 1) {
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    root(1, 0, 0);
    lnt tot = dfs(1), odd = getodd(1);
    writeln((tot - odd) / 2 + odd);
    return 0;
}


//Chaos///

#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#if DEBUG && !ONLINE_JUDGE

    #define debug(args...)     (Debugger()) , args
    //istringstream ss1(tmp11);
    class Debugger
    {
        public:
        Debugger(const std::string& _separator = ", ") :
        first(true), separator(_separator){}

        template<typename ObjectType>
        Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std::cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std::cerr << endl;}

        private:
        bool first;
        std::string separator;
    };

    template <typename T1, typename T2>
    inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
    {
        return os << "(" << p.first << ", " << p.second << ")";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
    {
        bool first = true;
        os << "[";
        for(unsigned int i = 0; i < v.size(); i++)
        {
            if(!first)
                os << ", ";
            os << v[i];
            first = false;
        }
        return os << "]";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
        {
            if(!first)
                os << ", ";
            os << *ii;
            first = false;
        }
        return os << "]";
    }

    template<typename T1, typename T2>
    inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
        {
            if(!first)
                os << ", ";
            os << *ii ;
            first = false;
        }
        return os << "]";
    }
#else
    #define debug(args...)
#endif
#define mod 1000000007
#define ok order_of_key
#define fo find_by_order
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repp(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define newl cout<<'\n'
#define inf 1000000000
#define repaa(i,a) for(auto i=a.begin();i!=a.end();++i)
#define pb push_back
#define test cout<<"test"<<endl
#define start int tt;cin>>tt;while(tt--)
#define tc int tt;tt=read();while(tt--)
#define nl "\n"
#define startk int tt;cin>>tt;for(int kk=1;kk<=tt;kk++)
#define mem(v,i) memset(v,i,sizeof(v))//Use mem(v,60) to initialize with 10^9
#define all(x) x.begin(), x.end()
#define inf1 1e18
#define repa(i,a) for (auto i : a)
#define X first
#define Y second
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define dec(v) sort(v.begin(),v.end(),greater<int>());
#define in(a,n) repp(jjj,n)cin>>a[jjj];
#define re(a,n) repp(jjj,n)a[jjj]=read();
#define retree(a,m) repp(i,m){int tmp1=read()-1,tmp2=read()-1;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}
#define intree(a,m) repp(i,m){int tmp1,tmp2;cin>>tmp1>>tmp2;tmp1--,tmp2--;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}
#define ins insert
#define er erase
#define sz(a) (int)(a.size())
#define big cpp_int
#define ll128 int128_t //Write (ll128) when using this type.
#define print(x,n,k) repp(i,n){repp(j,k)cout<<x[i][j]<<"  ";newl;}
#define mt make_tuple
#define eb emplace_back
#define p_q priority_queue
#define time cerr << 1.0 * clock()
#define bp(i) __builtin_popcount(i)
#define precision(x) cout << fixed << setprecision(x);
typedef long double ld;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pair<int,int>> vip;
typedef vector<pair<int,ll>> vil; // use for Dijkstra wih long weights
typedef vector<pair<ll,ll>> vll;
typedef pair<int, int> ip;
typedef pair<int, ll> il;
typedef pair<ll, ll> pll;
typedef tuple<int,int,int> state;
typedef tuple<ll,int,int> statel;
#ifdef Fading
#define gc getchar
#endif
#ifndef Fading
inline char gc(){
    static char now[1<<16],*S,*T;
    if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
    return *S++;
}
#endif
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
template<typename T>
T Min(T v) {
  return v;
}
template<typename T, typename... Args>
T Min(T first, Args... args) {
  return min(first , Min(args...));
}
template<typename T>
T Max(T v) {
  return v;
}
template<typename T, typename... Args>
T Max(T first, Args... args) {
  return max(first , Max(args...));
}
template<typename T>
T mult(T v) {
  return v;
}
template<typename T, typename... Args>
T mult(T first, Args... args) {
  return mult((first * mult(args...))%mod);
}
template<typename T>
T addr(T v) {
  return v;
}
template<typename T, typename... Args>
T addr(T first, Args... args) {
  return addr((first + addr(args...))%mod);
}
template<class T> inline void remin(T &a,T b){if(b<a) a=b;}
template<class T> inline void remax(T &a,T b){if(b>a) a=b;}
template<class A, class B>
void add(A &a, B b)//adds in a. Does not return anything.
{
    a += b;
    if (a < 0LL) a += mod;
    if (a >= mod) a -= mod;
}
template<class A, class B>
void mul(A &a, B b)//adds in a. Does not return anything.
{
    a=(a*b)%mod;
}
inline int to_i(char c)
{
    return c - 'a';
}
/*
int n;
const int NNNN=1000*1000+5;
ll BITTree1[NNNN],BITTree2[NNNN];
ll getSum(ll BITree[],int index){
    ll sum = 0;
    index++;
    while (index>0){
        sum += BITree[index];
        index -= index & (-index);
    }
    return sum;
}
void updateBIT(ll BITree[],int index,ll val){
    index++;
    while (index <= n){
        BITree[index] += val;
        index += index & (-index);
    }
}
int sum(int x){
    return getSum(BITTree1,x)*x-getSum(BITTree2,x);
}
void updateRange(int l,int r,int val){
    updateBIT(BITTree1,l,val);
    updateBIT(BITTree1,r+1,-val);
    updateBIT(BITTree2,l,val*(l-1));
    updateBIT(BITTree2,r+1,-val*r);
}
ll rangeSum(int l, int r){
    return sum(r)-sum(l-1);
}
*/
/*
const int NN=2*1000*100+4;
int dsu[NN],sub[NN];
int root(int a){
    while(dsu[a]!=a){
        dsu[a]=dsu[dsu[a]];
        a=dsu[a];
    }
    return a;
}
void uni(int a,int b){
    int _a=root(a);
    int _b=root(b);
    if(sub[_a]>sub[_b]){
        dsu[_b]=dsu[_a];
        sub[_a]+=sub[_b];
    }
    else {
        dsu[_a]=dsu[_b];
        sub[_b]+=sub[_a];
    }
}
*/
/*
const int LOGN=19,NNN=1000*1000+5;
int DP[LOGN][NN],level[NNN];
void dfs0(int u)
{
	for(auto it=a[u].begin();it!=a[u].end();it++)
		if(*it!=DP[0][u])
		{
			DP[0][*it]=u;
			level[*it]=level[u]+1;
			dfs0(*it);
		}
}
void preprocess()
{
	dfs0(0);
	for(int i=1;i<LOGN;i++)
		for(int j=0;j<n;j++)
			DP[i][j] = DP[i-1][DP[i-1][j]];
}
int lca(int a,int b)
{
	if(level[a]>level[b])swap(a,b);
	int d = level[b]-level[a];
	for(int i=0;i<LOGN;i++)
		if(d&(1<<i))
			b=DP[i][b];
	if(a==b)return a;
	for(int i=LOGN-1;i>=0;i--)
		if(DP[i][a]!=DP[i][b])
			a=DP[i][a],b=DP[i][b];
	return DP[0][a];
}
*/
/*
ll poww(ll a, ll b)
{
    ll val = 1;
    a %= mod;
    while (b > 0)
    {
        if (b % 2) val = mult(a, val);
        a = mult(a, a);
        b >>= 1;
    }
    return val % mod;
}
ll inv(ll a)
{
    return poww(a , mod - 2);
}
*/
/*
const int jj=2e5+5;
ll fac[jj];
void pre(){
    fac[0] = 1;
    for (int i=1 ; i<jj; i++)
    fac[i] = fac[i-1]*i%mod;
}
ll nc(int n,int r)
{
   if (r==0)
      return 1;
   return (fac[n]*inv(fac[r])%mod*inv(fac[n-r])%mod)%mod;
}
*/
/*
string to_str(ll a){
    string mystring;
    stringstream mystream;
    mystream << a;
    mystring = mystream.str();
    return mystring;
}
*/
/*
bool iscomp[100000];
vi primes;
void sieve(int n){
    for(int i=2;i<=n;++i){
        if(!iscomp[i]){
            primes.eb(i);
            for(int j=i*i;j<=n;j+=i)iscomp[j]=1;
        }
    }
}
*/
/*
vl prime(ll n){
    vl v;
    for(int i=2;i*i<=n;++i){
        if(n%i==0)v.eb(i);
        while(n%i==0)n/=i;
    }
    if(n!=1)v.eb(n);
    return v;
}
*/

//-----------------------------------------------------end--------------------------------------//

const int N=2e5+5;
ll dp[N];
vi a[N];
ll ans;
int sub[N];

void subtr(int no,int prev){
    sub[no]=1;
    repa(i,a[no]){
        if(i!=prev){
            subtr(i,no);
            sub[no]+=sub[i];
        }
    }
}

ll solve(int no,int prev){
    if(dp[no]!=-1)return dp[no];
    if(no!=0&&a[no].size()==1)return dp[no]=0;
    dp[no]=0;
    repa(i,a[no])if(i!=prev)dp[no]+=solve(i,no)+sub[i]-a[i].size()+1;
    return dp[no];
}

void reroot(int no,int prev){
    ans+=dp[no];
    repa(i,a[no]){
        if(i==prev)continue;
        dp[no]-=dp[i]+sub[i]-a[i].size()+1;
        sub[no]-=sub[i];
        sub[i]+=sub[no];
        dp[i]+=1+dp[no]+sub[no]-a[no].size();

        reroot(i,no);
        dp[i]-=1+dp[no]+sub[no]-a[no].size();
        sub[i]-=sub[no];
        sub[no]+=sub[i];
        dp[no]+=dp[i]+sub[i]-a[i].size()+1;
    }
}

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int n=read();
    if(n==1){cout<<0;return 0;}
    retree(a,n-1);
    mem(dp,-1);
    subtr(0,-1);
    solve(0,-1);
    reroot(0,-1);
    cout<<ans/2;
}


//Chaos///

#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#if DEBUG && !ONLINE_JUDGE

    #define debug(args...)     (Debugger()) , args
    //istringstream ss1(tmp11);
    class Debugger
    {
        public:
        Debugger(const std::string& _separator = ", ") :
        first(true), separator(_separator){}

        template<typename ObjectType>
        Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std::cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std::cerr << endl;}

        private:
        bool first;
        std::string separator;
    };

    template <typename T1, typename T2>
    inline std::ostream& operator << (std::ostream& os, const std::pair<T1, T2>& p)
    {
        return os << "(" << p.first << ", " << p.second << ")";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v)
    {
        bool first = true;
        os << "[";
        for(unsigned int i = 0; i < v.size(); i++)
        {
            if(!first)
                os << ", ";
            os << v[i];
            first = false;
        }
        return os << "]";
    }

    template<typename T>
    inline std::ostream &operator << (std::ostream & os,const std::set<T>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
        {
            if(!first)
                os << ", ";
            os << *ii;
            first = false;
        }
        return os << "]";
    }

    template<typename T1, typename T2>
    inline std::ostream &operator << (std::ostream & os,const std::map<T1, T2>& v)
    {
        bool first = true;
        os << "[";
        for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
        {
            if(!first)
                os << ", ";
            os << *ii ;
            first = false;
        }
        return os << "]";
    }
#else
    #define debug(args...)
#endif
#define mod 1000000007
#define ok order_of_key
#define fo find_by_order
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repp(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define repl(i,a,b) for(ll i=(a);i<(b);i++)
#define newl cout<<'\n'
#define inf 1000000000
#define repaa(i,a) for(auto i=a.begin();i!=a.end();++i)
#define pb push_back
#define test cout<<"test"<<endl
#define start int tt;cin>>tt;while(tt--)
#define tc int tt;tt=read();while(tt--)
#define nl "\n"
#define startk int tt;cin>>tt;for(int kk=1;kk<=tt;kk++)
#define mem(v,i) memset(v,i,sizeof(v))//Use mem(v,60) to initialize with 10^9
#define all(x) x.begin(), x.end()
#define inf1 1e18
#define repa(i,a) for (auto i : a)
#define X first
#define Y second
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define dec(v) sort(v.begin(),v.end(),greater<int>());
#define in(a,n) repp(jjj,n)cin>>a[jjj];
#define re(a,n) repp(jjj,n)a[jjj]=read();
#define retree(a,m) repp(i,m){int tmp1=read()-1,tmp2=read()-1;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}
#define intree(a,m) repp(i,m){int tmp1,tmp2;cin>>tmp1>>tmp2;tmp1--,tmp2--;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}
#define ins insert
#define er erase
#define sz(a) (int)(a.size())
#define big cpp_int
#define ll128 int128_t //Write (ll128) when using this type.
#define print(x,n,k) repp(i,n){repp(j,k)cout<<x[i][j]<<"  ";newl;}
#define mt make_tuple
#define eb emplace_back
#define p_q priority_queue
#define time cerr << 1.0 * clock()
#define bp(i) __builtin_popcount(i)
#define precision(x) cout << fixed << setprecision(x);
typedef long double ld;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pair<int,int>> vip;
typedef vector<pair<int,ll>> vil; // use for Dijkstra wih long weights
typedef vector<pair<ll,ll>> vll;
typedef pair<int, int> ip;
typedef pair<int, ll> il;
typedef pair<ll, ll> pll;
typedef tuple<int,int,int> state;
typedef tuple<ll,int,int> statel;
#ifdef Fading
#define gc getchar
#endif
#ifndef Fading
inline char gc(){
    static char now[1<<16],*S,*T;
    if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
    return *S++;
}
#endif
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
template<typename T>
T Min(T v) {
  return v;
}
template<typename T, typename... Args>
T Min(T first, Args... args) {
  return min(first , Min(args...));
}
template<typename T>
T Max(T v) {
  return v;
}
template<typename T, typename... Args>
T Max(T first, Args... args) {
  return max(first , Max(args...));
}
template<typename T>
T mult(T v) {
  return v;
}
template<typename T, typename... Args>
T mult(T first, Args... args) {
  return mult((first * mult(args...))%mod);
}
template<typename T>
T addr(T v) {
  return v;
}
template<typename T, typename... Args>
T addr(T first, Args... args) {
  return addr((first + addr(args...))%mod);
}
template<class T> inline void remin(T &a,T b){if(b<a) a=b;}
template<class T> inline void remax(T &a,T b){if(b>a) a=b;}
template<class A, class B>
void add(A &a, B b)//adds in a. Does not return anything.
{
    a += b;
    if (a < 0LL) a += mod;
    if (a >= mod) a -= mod;
}
template<class A, class B>
void mul(A &a, B b)//adds in a. Does not return anything.
{
    a=(a*b)%mod;
}
inline int to_i(char c)
{
    return c - 'a';
}
/*
int n;
const int NNNN=1000*1000+5;
ll BITTree1[NNNN],BITTree2[NNNN];
ll getSum(ll BITree[],int index){
    ll sum = 0;
    index++;
    while (index>0){
        sum += BITree[index];
        index -= index & (-index);
    }
    return sum;
}
void updateBIT(ll BITree[],int index,ll val){
    index++;
    while (index <= n){
        BITree[index] += val;
        index += index & (-index);
    }
}
int sum(int x){
    return getSum(BITTree1,x)*x-getSum(BITTree2,x);
}
void updateRange(int l,int r,int val){
    updateBIT(BITTree1,l,val);
    updateBIT(BITTree1,r+1,-val);
    updateBIT(BITTree2,l,val*(l-1));
    updateBIT(BITTree2,r+1,-val*r);
}
ll rangeSum(int l, int r){
    return sum(r)-sum(l-1);
}
*/
/*
const int NN=2*1000*100+4;
int dsu[NN],sub[NN];
int root(int a){
    while(dsu[a]!=a){
        dsu[a]=dsu[dsu[a]];
        a=dsu[a];
    }
    return a;
}
void uni(int a,int b){
    int _a=root(a);
    int _b=root(b);
    if(sub[_a]>sub[_b]){
        dsu[_b]=dsu[_a];
        sub[_a]+=sub[_b];
    }
    else {
        dsu[_a]=dsu[_b];
        sub[_b]+=sub[_a];
    }
}
*/
/*
const int LOGN=19,NNN=1000*1000+5;
int DP[LOGN][NN],level[NNN];
void dfs0(int u)
{
	for(auto it=a[u].begin();it!=a[u].end();it++)
		if(*it!=DP[0][u])
		{
			DP[0][*it]=u;
			level[*it]=level[u]+1;
			dfs0(*it);
		}
}
void preprocess()
{
	dfs0(0);
	for(int i=1;i<LOGN;i++)
		for(int j=0;j<n;j++)
			DP[i][j] = DP[i-1][DP[i-1][j]];
}
int lca(int a,int b)
{
	if(level[a]>level[b])swap(a,b);
	int d = level[b]-level[a];
	for(int i=0;i<LOGN;i++)
		if(d&(1<<i))
			b=DP[i][b];
	if(a==b)return a;
	for(int i=LOGN-1;i>=0;i--)
		if(DP[i][a]!=DP[i][b])
			a=DP[i][a],b=DP[i][b];
	return DP[0][a];
}
*/
/*
ll poww(ll a, ll b)
{
    ll val = 1;
    a %= mod;
    while (b > 0)
    {
        if (b % 2) val = mult(a, val);
        a = mult(a, a);
        b >>= 1;
    }
    return val % mod;
}
ll inv(ll a)
{
    return poww(a , mod - 2);
}
*/
/*
const int jj=2e5+5;
ll fac[jj];
void pre(){
    fac[0] = 1;
    for (int i=1 ; i<jj; i++)
    fac[i] = fac[i-1]*i%mod;
}
ll nc(int n,int r)
{
   if (r==0)
      return 1;
   return (fac[n]*inv(fac[r])%mod*inv(fac[n-r])%mod)%mod;
}
*/
/*
string to_str(ll a){
    string mystring;
    stringstream mystream;
    mystream << a;
    mystring = mystream.str();
    return mystring;
}
*/
/*
bool iscomp[100000];
vi primes;
void sieve(int n){
    for(int i=2;i<=n;++i){
        if(!iscomp[i]){
            primes.eb(i);
            for(int j=i*i;j<=n;j+=i)iscomp[j]=1;
        }
    }
}
*/
/*
vl prime(ll n){
    vl v;
    for(int i=2;i*i<=n;++i){
        if(n%i==0)v.eb(i);
        while(n%i==0)n/=i;
    }
    if(n!=1)v.eb(n);
    return v;
}
*/

//-----------------------------------------------------end--------------------------------------//

const int N=2e5+5;
ll dp[N];
vi a[N];
ll ans;
int subodd[N],subeven[N];

void subtr(int no,int prev){
    subeven[no]=1;
    repa(i,a[no]){
        if(i!=prev){
            subtr(i,no);
            subodd[no]+=subeven[i];
            subeven[no]+=subodd[i];
        }
    }
}

ll solve(int no,int prev){
    if(dp[no]!=-1)return dp[no];
    if(no!=0&&a[no].size()==1)return dp[no]=0;
    dp[no]=0;
    repa(i,a[no])if(i!=prev)dp[no]+=solve(i,no)+subeven[i];
    return dp[no];
}

void reroot(int no,int prev){
    ans+=dp[no];//cout<<no<<' '<<dp[no]<<endl;
    repa(i,a[no]){
        if(i==prev)continue;
        dp[no]-=dp[i]+subeven[i];
        subeven[no]-=subodd[i];
        subodd[no]-=subeven[i];
        subeven[i]+=subodd[no];
        subodd[i]+=subeven[no];
        dp[i]+=dp[no]+subeven[no];
        reroot(i,no);
        dp[i]-=dp[no]+subeven[no];
        subeven[i]-=subodd[no];
        subodd[i]-=subeven[no];
        subeven[no]+=subodd[i];
        subodd[no]+=subeven[i];
        dp[no]+=dp[i]+subeven[i];
    }
}

int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int n=read();
    if(n==1){cout<<0;return 0;}
    retree(a,n-1);
    mem(dp,-1);
    subtr(0,-1);
    solve(0,-1);//repp(i,n)cout<<dp[i]<<endl;
    reroot(0,-1);
    cout<<ans/2;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <set>
#include <cmath>

using namespace std;
typedef long long ll;
const int MAXN = 200100;

int N;
vector <int> edge[MAXN];
int ddep[MAXN], ssize[MAXN];

void flood (int cloc, int last)
{
    ssize[cloc] = 1;
    for (int neigh : edge[cloc])
    {
        if (neigh == last) continue;
        ddep[neigh] = ddep[cloc] + 1;
        flood (neigh, cloc);
        ssize[cloc] += ssize[neigh];
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    cin >> N;
    for (int i = 0; i < N - 1; i++)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }

    flood (0, -1);
    ll nodd = 0;
    ll res = 0;
    for (int i = 1; i < N; i++)
    {
        res += ssize[i] * (ll) (N - ssize[i]);//cout<<res<<endl;
        if (ddep[i] % 2 == 0)
            nodd++;
    }//cout<<res<<endl;
    nodd++;
    res += nodd * (ll) (N - nodd);
    cout << res / 2 << "\n";
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define clr(x) memset(x, 0, sizeof(x))
#define cpy(x,y) memcpy(x, y, sizeof(y))
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

char __buffer[100000];

#ifdef _DEBUG
#define LOCAL
#endif

void err(const char *format, ... ) {
#ifdef LOCAL
	va_list ap;
	va_start(ap, format);
	vsprintf(__buffer, format, ap);
	va_end(ap);

	fprintf(stderr, "\t%s", __buffer);
#else
	if (format < 0) {
		__buffer[0]++;
	}
#endif
}

void errln(const char *format, ... ) {
#ifdef LOCAL
	va_list ap;
	va_start(ap, format);
	vsprintf(__buffer, format, ap);
	va_end(ap);

	fprintf(stderr, "\t%s\n", __buffer);
#else
	if (format < 0) {
		__buffer[0]++;
	}
#endif
}

void errln() {
#ifdef LOCAL
	fprintf(stderr, "\n");
#endif
}

double START_TIME;

void exit() {
#ifdef LOCAL
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#define dbg1(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 1; ABC <= n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#define dbg1(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

///////////////////////////////////////////////////

const int MAX = 200 * 1000 + 41;

int n;
vi e[MAX];
int col[MAX];
int dq[MAX][2];

ll d[MAX][2];
ll ans;

void dfs0(int x, int p = -1) {
	dq[x][col[x]] = 1;
	for (int y : e[x]) {
		if (y == p) continue;
		col[y] = 1 - col[x];
		dfs0(y, x);
		dq[x][0] += dq[y][0];
		dq[x][1] += dq[y][1];
	}
}

void dfs(int x, int p = -1) {
	for (int y : e[x]) {
		if (y == p) continue;
		dfs(y, x);
	}

	for (int y : e[x]) {
		if (y == p) continue;
		fo(0, 1) {
			int f = (col[x] == o ? 0 : 1);
			d[x][o] += d[y][o] + f * dq[y][o];
		}
	}

	int cnt = dq[x][0] + dq[x][1] - 1;

	for (int y : e[x]) {
		if (y == p) continue;
		ll l = d[y][0] + d[y][1];
		ll q = cnt - dq[y][0] - dq[y][1];
		ll toadd = l * q;
//		err("x = %d y = %d l = %lld q = %lld toadd = %lld\n", x, y, l, q, toadd);
		ans += toadd;
	}

	ll add1 = 0;
	for (int y : e[x]) {
		if (y == p) continue;
		ll q = cnt - dq[y][0] - dq[y][1];
		add1 += q * (dq[y][0] + dq[y][1]);
	}

	for (int y : e[x]) {
		if (y == p) continue;
		add1 -= (ll) dq[y][col[x]] * (dq[x][col[x]] - dq[y][col[x]] - 1);
	}

	ass(add1 % 2 == 0);
	ans += add1 / 2;

	ans += d[x][0] + d[x][1];

	err("x = %d d0 = %lld d1 = %lld\n", x, d[x][0], d[x][1]);
}

void solve() {
	dfs0(1);
	dfs(1);
	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif

	scanf("%d", &n);
	fi(1, n - 1) {
		int x, y;
		scanf("%d %d", &x, &y);
		e[x].pb(y);
		e[y].pb(x);
	}
	solve();

	exit();
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define clr(x) memset(x, 0, sizeof(x))
#define cpy(x,y) memcpy(x, y, sizeof(y))
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

char __buffer[100000];

#ifdef _DEBUG
#define LOCAL
#endif

void err(const char *format, ... ) {
#ifdef LOCAL
	va_list ap;
	va_start(ap, format);
	vsprintf(__buffer, format, ap);
	va_end(ap);

	fprintf(stderr, "\t%s", __buffer);
#else
	if (format < 0) {
		__buffer[0]++;
	}
#endif
}

void errln(const char *format, ... ) {
#ifdef LOCAL
	va_list ap;
	va_start(ap, format);
	vsprintf(__buffer, format, ap);
	va_end(ap);

	fprintf(stderr, "\t%s\n", __buffer);
#else
	if (format < 0) {
		__buffer[0]++;
	}
#endif
}

void errln() {
#ifdef LOCAL
	fprintf(stderr, "\n");
#endif
}

double START_TIME;

void exit() {
#ifdef LOCAL
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#define dbg1(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 1; ABC <= n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#define dbg1(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

///////////////////////////////////////////////////

const int MAX = 200 * 1000 + 41;

int n;
vi e[MAX];
int col[MAX];
int dq[MAX][2];

ll d[MAX][2];
ll ans;

void dfs0(int x, int p = -1) {
	dq[x][col[x]] = 1;
	for (int y : e[x]) {
		if (y == p) continue;
		col[y] = 1 - col[x];
		dfs0(y, x);
		dq[x][0] += dq[y][0];
		dq[x][1] += dq[y][1];
	}
}

void dfs(int x, int p = -1) {
	for (int y : e[x]) {
		if (y == p) continue;
		dfs(y, x);
	}

	for (int y : e[x]) {
		if (y == p) continue;
		fo(0, 1) {
			int f = (col[x] == o ? 0 : 1);
			d[x][o] += d[y][o] + f * dq[y][o];
		}
	}

	int cnt = dq[x][0] + dq[x][1] - 1;
	for (int y : e[x]) {
		if (y == p) continue;
		ll l = d[y][0] + d[y][1];
		ll q = cnt - dq[y][0] - dq[y][1];
		ll toadd = l * q;
//		err("x = %d y = %d l = %lld q = %lld toadd = %lld\n", x, y, l, q, toadd);
		ans += toadd;
	}

	ll add1 = 0;
	for (int y : e[x]) {
		if (y == p) continue;
		ll q = cnt - dq[y][0] - dq[y][1];
		add1 += q * (dq[y][0] + dq[y][1]);
	}

	ass(add1 % 2 == 0);
	ans += add1 / 2;

	ans += d[x][0] + d[x][1];

	err("x = %d d0 = %lld d1 = %lld\n", x, d[x][0], d[x][1]);
}

void solve() {
	dfs0(1);
	dfs(1);
	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif

	scanf("%d", &n);
	fi(1, n - 1) {
		int x, y;
		scanf("%d %d", &x, &y);
		e[x].pb(y);
		e[y].pb(x);
	}
	solve();

	exit();
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define clr(x) memset(x, 0, sizeof(x))
#define cpy(x,y) memcpy(x, y, sizeof(y))
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

char __buffer[100000];

#ifdef _DEBUG
#define LOCAL
#endif

void err(const char *format, ... ) {
#ifdef LOCAL
	va_list ap;
	va_start(ap, format);
	vsprintf(__buffer, format, ap);
	va_end(ap);

	fprintf(stderr, "\t%s", __buffer);
#else
	if (format < 0) {
		__buffer[0]++;
	}
#endif
}

void errln(const char *format, ... ) {
#ifdef LOCAL
	va_list ap;
	va_start(ap, format);
	vsprintf(__buffer, format, ap);
	va_end(ap);

	fprintf(stderr, "\t%s\n", __buffer);
#else
	if (format < 0) {
		__buffer[0]++;
	}
#endif
}

void errln() {
#ifdef LOCAL
	fprintf(stderr, "\n");
#endif
}

double START_TIME;

void exit() {
#ifdef LOCAL
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#define dbg1(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 1; ABC <= n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#define dbg1(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

///////////////////////////////////////////////////

const int MAX = 200 * 1000 + 41;

int n;
vi e[MAX];

ll dq[MAX][2];
ll dsum[MAX][2];
int col[MAX];

void dfs0(int x, int p = -1) {
	dq[x][col[x]] = 1;
	for (int y : e[x]) {
		if (y == p) continue;
		col[y] = 1 - col[x];
		dfs0(y, x);
		fo(0, 1) {
			dq[x][o] += dq[y][o];
		}
	}
}

ll ans;

void dfs(int x, int p = -1) {
	for (int y : e[x]) {
		if (y == p) continue;
		dfs(y, x);
	}

	for (int y : e[x]) {
		if (y == p) continue;
		fo(0, 1) {
			int f = (o == col[x] ? 0 : 1);
			dsum[x][col[x]] += dsum[y][o] + f * (dq[y][o]);
		}
	}

	ll cnt = 0;

	vi all;

	for (int y : e[x]) {
		if (y == p) continue;
		cnt += dq[y][0] + dq[y][1];
		all.pb(y);
	}

	ll add = 0;
	for (auto z : all) {
		ll cur = dsum[z][0] + dsum[z][1];
		ll toadd = (cur + 1) * (sz(all) - 1);
		add += toadd;
	}
	ans += dsum[x][0] + dsum[x][1];
	ans += add / 2;
}

void solve() {
	dfs0(1);
	dfs(1);
	printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif

  scanf("%d", &n);
  fi(1, n - 1) {
  	int x, y;
  	scanf("%d %d", &x, &y);
  	e[x].pb(y);
  	e[y].pb(x);
  }

	solve();

	exit();
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi(a, b) for(int i=a; i<=b; i++)
#define fj(a, b) for(int j=a; j<=b; j++)
#define fo(a, b) for(int o=a; o<=b; o++)
#define fdi(a, b) for(int i=a; i>=b; i--)
#define fdj(a, b) for(int j=a; j>=b; j--)
#define fdo(a, b) for(int o=a; o>=b; o--)
#define clr(x) memset(x, 0, sizeof(x))
#define cpy(x,y) memcpy(x, y, sizeof(y))
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

char __buffer[100000];

#ifdef _DEBUG
#define LOCAL
#endif

void err(const char *format, ... ) {
#ifdef LOCAL
	va_list ap;
	va_start(ap, format);
	vsprintf(__buffer, format, ap);
	va_end(ap);

	fprintf(stderr, "\t%s", __buffer);
#else
	if (format < 0) {
		__buffer[0]++;
	}
#endif
}

void errln(const char *format, ... ) {
#ifdef LOCAL
	va_list ap;
	va_start(ap, format);
	vsprintf(__buffer, format, ap);
	va_end(ap);

	fprintf(stderr, "\t%s\n", __buffer);
#else
	if (format < 0) {
		__buffer[0]++;
	}
#endif
}

void errln() {
#ifdef LOCAL
	fprintf(stderr, "\n");
#endif
}

double START_TIME;

void exit() {
#ifdef LOCAL
	cerr << "TIME: " << setprecision(5) << fixed << (clock() - START_TIME) / CLOCKS_PER_SEC << endl;
#endif
	exit(0);
}

template<typename A, typename B>
ostream& operator<<(ostream& os, pair<A, B> p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
	fi(0, sz(v) - 1) {
		os << v[i] << " ";
	}
	return os;
}

template<typename T>
ostream& operator<<(ostream& os, set<T> t) {
	for (auto z : t) {
		os << z << " ";
	}
	return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2> t) {
	cerr << endl;
	for (auto z : t) {
		os << "\t" << z.first << " -> " << z.second << endl;
	}
	return os;
}

#ifdef LOCAL
#define dbg(x) {cerr << __LINE__ << "\t" << #x << ": " << x << endl;}
#define dbg0(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 0; ABC < n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#define dbg1(x, n) {cerr << __LINE__ << "\t" << #x << ": "; for (int ABC = 1; ABC <= n; ABC++) cerr << x[ABC] << ' '; cerr << endl;}
#else
#define dbg(x) while(0){}
#define dbg0(x, n) while(0){}
#define dbg1(x, n) while(0){}
#endif

#ifdef LOCAL
#define ass(x) if (!(x)) { cerr << __LINE__ << "\tassertion failed: " << #x << endl, abort(); }
#else
#define ass(x) assert(x)
#endif

///////////////////////////////////////////////////

const int MAX = 200 * 1000 + 41;

int n;
vi e[MAX];
int col[MAX];
int dq[MAX][2];
ll ds[MAX][2];
bool u[MAX];
ll d[MAX];

int par[MAX];

void dfs0(int x, int p = -1) {
	par[x] = p;
	dq[x][col[x]] = 1;
	for (int y : e[x]) {
		if (y == p) continue;
		col[y] = 1 - col[x];
		dfs0(y, x);
		dq[x][0] += dq[y][0];
		dq[x][1] += dq[y][1];
		ds[x][col[x]] += ds[y][col[x]];
		ds[x][1 - col[x]] += ds[y][1 - col[x]] + dq[y][1 - col[x]];
	}
}

ll ans;

ll fun(int x) {
	if (x == -1) return 0LL;
	if (u[x]) return d[x];

	ll res = fun(par[x]);
	res += (dq[1][1 - col[x]] - dq[x][1 - col[x]]);
	if (par[x] != -1) {
	  res -= dq[x][col[x]];
	} else {
		res += ds[x][0] + ds[x][1];
	}

	u[x] = 1;
	return d[x] = res;
}

void solve() {
	dfs0(1);
	fi(1, n) {
		fun(i);
	}

	fi(1, n) {
		ans += d[i];
	}
	ass(ans % 2 == 0);
	printf("%lld\n", ans / 2);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	START_TIME = (double)clock();
#endif

  scanf("%d", &n);
  fi(1, n - 1) {
  	int x, y;
  	scanf("%d %d", &x, &y);
  	e[x].pb(y);
  	e[y].pb(x);
  }
	solve();

	exit();
	return 0;
}


# include <stdio.h>
# include <bits/stdc++.h>

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++)
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int n, m, x;
int d[N], cnt[N];
int sz[N];
int u[N];
ll ans = 0, res = 0;
ll f[N];
ll pre, c;
vector < int > g[N];

void DFS (int v, int pr = 0) {
    sz[v] = 1;
    ans += (d[v] > 1);
    int cnt = g[v].size();
    if (pr) cnt --;
    ans += 1ll * cnt * (cnt - 1) / 2ll;
    for (auto to : g[v]) {
        if (to == pr) continue;
        d[to] = d[v] + 1;
        DFS (to, v);
        sz[v] += sz[to];
    }
}

void dfs (int v, int p) {
	sz[v] = 1;
	for (int to : g[v]) {
		if (to == p || u[to]) continue;
		dfs(to, v);
		sz[v] += sz[to];
	}
}

int get_center (int v) {
    int p = v, Sz = sz[v], ch = 1;
    while (ch) {
    	ch = 0;
    	for (int to : g[v]) {
    		if (u[to] || p == to) continue;
    		if (sz[to] * 2 >= Sz) {
    			p = v, v = to, ch = 1;
    			break;
    		}
    	}
    }

	return v;
}

void add (int v, int p, int dist) {
    res += dist *c + pre;

  	for (int to : g[v]) {
    	if (to == p || u[to]) continue;
      	add (to, v, dist + 1);
  	}
}
void calc (int v, int p, int dist){
    pre += dist;

  	for (int to : g[v]) {
  		if (to == p || u[to]) continue;
    	calc (to, v, dist + 1);
  	}
}

void solve (int v, int p) {
	dfs(v, v);
	v = get_center(v);
	pre = 0;
	c = 0;
	for (int to : g[v]) {

		if (!u[to]) {
		    c ++;
		    //cout << res << ' ' << pre << '\n';
			add (to, v, 1);
			//cout << res << ' ' << pre << '\n';
			calc (to, v, 1);
		}
	}

	u[v] = 1;
	for (int to : g[v]) {
		if (!u[to]) {
			solve(to, v);
		}
	}
}

int main () {
    cin >> n;

    For (i, 2, n) {
        int l, r;
        cin >> l >> r;
        g[l].pb(r);
        g[r].pb(l);
    }

    DFS(1);
    solve(1, 1);
    //cout << res << ' ' << ans << '\n';
    cout << res - ans;
	return Accepted;
}

// Coded By OB


readline()
var arr = readline().split(' ').map(v => +v.trim());
var even = 0, odd = 0;

for (var i = 0; i < arr.length; i++) {
  if (arr[i] % 2 == 0) {
    even += 1;
  } else {
    odd += 1;
  }
}

var ans = 0;
if (even > odd) {
  print(odd);
} else {
  ans += even;
  odd -= even;

  ans += Math.floor(even / 2);

  print(ans);
}


var nk = readline().split(' ').map(v => +v.trim());
var n = nk[0];
var arr = readline().split(' ').map(v => +v.trim());
var even = 0, odd = 0;

for (var i = 0; i < n; i++) {
  if (arr[i] % 2 == 0) {
    even += 1;
  } else {
    odd += 1;
  }
}

var ans = 0;
if (even > odd) {
  print(odd);
} else {
  ans += even;
  odd -= even;

  ans += Math.floor(odd / 3);

  print(ans);
}


var nn = readline();
var n = parseInt(nn, 10);
var a = readline().split(" ");
var even = 0;
var odd = 0;
for (var i = 0; i < n; ++i) {
    var cur = parseInt(a[i], 10);
    if (cur % 2 === 0) {
        ++even;
    }
    else {
        ++odd;
    }
}
var ans = 0;
if (even >= odd) {
    ans = odd;
}
else {
    ans = even + ((odd - even) / 3);
}
ans = Math.floor(ans);
print(ans);


var now=readline().split(' ').map(function(v){return +v;});
var n=now[0];
var num=readline().split(' ').map(function(v){return +v;});
var i=0;
var cnto=0,cnte=0;
while(i<n) {
    if(num[i]%2==1)
        cnto=cnto+1;
    else
        cnte=cnte+1;
    i++;
}
var ans=0;
if(cnto<cnte)
    ans=cnto;
else
    ans=cnte+Math.floor((cnto-cnte)/3);
print(ans);


//var print = require('lol-io').print
//var readline = require('lol-io').readline
var n = parseInt(readline());
var t = readline().split(' ');
var a = [];
var odd = 0;
var even = 0;
for (var i=0;i<n;i++){
    a.push(parseInt(t[i]));
}
for (var i=0;i<n;i++){
    if (a[i]%2==0){
        even++;
    }
    else {
        odd++;
    }
}
if (even > odd){
    print(odd);
}
else {
    var ans = even;
    odd -= even;
    print(ans + parseInt(odd / 3));
}


var n = readline();
var arr = readline().split(" ").map(v => +v.trim());

var x = 0;
var y = 0;
for(var i = 0; i < n; i++) {
    if (arr[i] % 2 == 0) x++; else y++;
}

var res = 0;
if (x > y) res = y;
else {
    res = x;
    y = y - x;
    res = res + Math.floor(y/3);
}

print(res);


const firstLine = readline();
const n = firstLine.split(' ')[0];
var arr = readline().split(" ").map(v => +v.trim());

var ctn = 0;
var ctch = 0;
for(var i = 0; i < n; i++){
    if (arr[i] % 2 === 0)
    	ctch++;
    else ctn++;
}
// print(ctch);
// print(ctn);
var k = 0;
if (ctch <= ctn)
k = ctch;
else k = ctn;
ctch -= k;
ctn -= k;
var min = 0;
if (ctn % 3 >= ctch / 2)
min = ctch / 2;
else min = ctn % 3;
var ans1 = ctn / 3 + min;
if (ctch / 2 > ctn)
min = ctn;
else min = ctch / 2;
var ans2 = min;
if (ctn - ans2 > 0)
ans2 += (ctn - ans2) / 3;

if (ans1 > ans2)
k += ans1;
else k += ans2;
print(k);


const firstLine = readline();
const n = firstLine.split(' ')[0];
var arr = readline().split(" ").map(v => +v.trim());

var ctn = 0;
var ctch = 0;
for(var i = 0; i < n; i++){
    if (arr[i] % 2 === 0)
    	ctch++;
    else ctn++;
}
// print(ctch);
// print(ctn);
var k = 0;
if (ctch <= ctn)
k = ctch;
else k = ctn;
ctch -= k;
ctn -= k;
var min = 0;
if (ctn % 3 >= parseInt(ctch / 2))
min = parseInt(ctch / 2);
else min = ctn % 3;
var ans1 = parseInt(ctn / 3) + min;
if (parseInt(ctch / 2) > ctn)
min = ctn;
else min = parseInt(ctch / 2);
var ans2 = min;
if (ctn - ans2 > 0)
ans2 += parseInt((ctn - ans2) / 3);

if (ans1 > ans2)
k += ans1;
else k += ans2;
print(k);


ns = readline().split(' ')
n = parseInt(ns[0], 10);

fl = readline().split(' ')

ev = 0
odd = 0

for (i = 0; i < n; ++i)
{
	if (parseInt(fl[i], 10) % 2 === 0)
		++ev;
	else
		++odd;
}

if (ev >= odd)
{
	ans = odd;
}
else
{

	ans = ev + Math.floor((odd - ev) / 3);
}

print(ans)


ns = readline().split(' ')
n = parseInt(ns[0], 10);

fl = readline().split(' ')

ev = 0
odd = 0

for (i = 0; i < n; ++i)
{
	if (parseInt(fl[i], 10) % 2 === 0)
		++ev;
	else
		++odd;
}

if (ev > odd)
	ans = odd;
else
	ans = ev;

print(ans)


var n = readline().split(" ").map(v => +v.trim())[0];
var a = readline().split(" ").map(v => +v.trim());

var odd = 0;
var even = 0;

for (var i = 0; i < n; i++)
{
	if(a[i] % 2 === 0)
		even += 1;
	else
		odd += 1;
}

if (odd > even)
	print(even);
else
	print(odd);


var n = readline().split(" ").map(v => +v.trim())[0];
var a = readline().split(" ").map(v => +v.trim());

var odd = 0;
var even = 0;

for (var i = 0; i < n; i++)
{
	if(a[i] % 2 === 0)
		even += 1;
	else
		odd += 1;
}

if (even > odd)
	print(odd);
else
	print(even + parseInt((odd - even)/3));


var n = readline();
var input = readline().split(" ");
var ans1=0;
var ans2=0;

for(var i = 0; i < n; i++){
	if(input[i] %2 ==0)
		ans1++;
	else ans2++;
}
var hlp=(ans2-ans1)-(ans2-ans1)%3;
hlp=hlp/3;
if(ans1>ans2)
print(ans2);
else print(ans1+hlp);


var n = readline();
var input = readline().split(" ");
var ans1=0;
var ans2=0;

for(var i = 0; i < n; i++){
	if(input[i] %2 ==0)
		ans1++;
	else ans2++;
}
var hlp=(ans1-ans2)-(ans1-ans2)%3;
hlp=hlp/3;
if(ans1>ans2)
print(ans2+hlp);
else print(ans1);


var n = readline();
var input = readline().split(" ");
var ans1=0;
var ans2=0;

for(var i = 0; i < n; i++){
	if(input[i] %2 ==0)
		ans1++;
	else ans2++;
}
if(ans1>ans2)
print(ans2+(ans1-ans2)/3);
else print(ans1);


var n = readline();
var input = readline().split(" ");
var ans1=0;
var ans2=0;

for(var i = 0; i < n; i++){
	if(input[i] %2 ==0)
		ans1++;
	else ans2++;
}
if(ans1>ans2)
print(ans2);
else print(ans1);


var n = readline();
var input = readline().split(" ");
var ans1=0;
var ans2=0;

for(var i = 0; i < n; i++){
	if(input[i] %2 ==0)
		ans1++;
	else ans2++;
}
if(ans1>ans2)
print(ans2+((ans1-ans2)/3));
else print(ans1);


var n = readline();
var chet = 0 , nechet = 0 , maxx=0;
var arr = readline().split(" ").map(v => +v.trim());
for(var i = 0; i < n; i++){
    if (arr[i]%2 === 0){
        chet++;
    }else{
        nechet++;
    }
}
if (chet>=nechet){
    print(nechet);
}else{
    if (nechet===1){
        print(0);
    }else{
        while (chet<nechet){
            if (chet>maxx)maxx=chet;
            chet++;
            nechet-=2;
        }
    if (nechet>maxx)maxx=nechet;
    print(maxx);
    }
}


var n = readline();
var chet = 0 , nechet = 0;
var arr = readline().split(" ").map(v => +v.trim());
for(var i = 0; i < n; i++){
    if (arr[i]%2 === 0){
        chet++;
    }else{
        nechet++;
    }
}
if (chet>nechet){
    print(nechet);
}else{
    if (nechet===1){
        print(0);
    }else{
        while (chet<nechet){
            chet++;
            nechet-=2;
        }
    print(nechet);
    }
}


var n = readline();
var chet = 0 , nechet = 0;
var arr = readline().split(" ").map(v => +v.trim());
for(var i = 0; i < n; i++){
    if (arr[i]%2 === 0){
        chet++;
    }else{
        nechet++;
    }
}
if (chet>=nechet){
    print(nechet);
}else{
    if (nechet===1){
        print(0);
    }else{
        while (chet<nechet){
            chet++;
            nechet-=2;
        }
    print(nechet);
    }
}


var n = readline();
var chet = 0 , nechet = 0;
var arr = readline().split(" ").map(v => +v.trim());
for(var i = 0; i < n; i++){
    if (arr[i]%2 === 0){
        chet++;
    }else{
        nechet++;
    }
}
if (chet>nechet){
    print(nechet);
}else{
    while (chet<nechet){
        chet++;
        nechet-=2;
    }
    print(nechet)
}


var L = readline().split(' ');
var n = parseInt(L[0]);
var arr = readline().split(' ');
var ans = 0;
for(var i = 0;i < n;i++){
  if(parseInt(arr[i])%2 === 1) ans++;
}
print(ans);


var L = readline().split(' ');
var n = parseInt(L[0]);
var arr = readline().split(' ');
var ans = 0, k  = 0;
for(var i = 0;i < n;i++){
  if(parseInt(arr[i])%2 === 1) ans++;
  else k++;
}
if(k > ans) print(ans);
else{
    var d = k;
    d += ((ans-k) - ((ans-k)%3))/3;
    print(d);
}


var arr = readline().split(" ").map(v => +v.trim());
var n = arr[0];
var a = readline().split(" ").map(v => +v.trim());
kch=0
knch=0
for (var i=0;i<n;i++){
    if (a[i]%2===0){
        kch++;
    }
    else{
        knch++;
    }
}
if (knch<kch){
    print(knch);
}
else{
    print(kch+Math.floor((knch-kch)/3));
}


var arr = readline().split(" ").map(v => +v.trim());
var n = arr[0];
var a = readline().split(" ").map(v => +v.trim());
kch=0
knch=0
for (var i=0;i<n;i++){
    if (a[i]%2===0){
        kch++;
    }
    else{
        knch++;
    }
}
if (knch<kch){
    print(knch);
}
else{
    print(kch+(knch-kch)/3);
}


var now=readline().split(' ').map(function(v){return +v;});
var n=now[0];
var num=readline().split(' ').map(function(v){return +v;});
var i=0;
var cnto=0,cnte=0;
while(i<n) {
    if(num[i]%2==1) {
        cnto=cnto+1;
    }
    else {
        cnte=cnte+1;
    }
    i++;
}
var ans=0;
if(cnto<cnte)
    ans=cnto;
else
    ans=cnte;
print(ans);


var now=readline().split(' ').map(function(v){return +v;});
var n=now[0];
var num=readline().split(' ').map(function(v){return +v;});
var i=0;
var cnto=0,cnte=0;
while(i<n) {
    if(num[i]%2==1)
        cnto=cnto+1;
    else
        cnte=cnte+1;
    i++;
}
var ans=0;
if(cnto<cnte)
    ans=cnto;
else
    ans=cnte+(cnto-cnte)/3;
print(ans);


var now=readline().split(' ').map(function(v){return +v;});
var n=now[0];
var num=readline().split(' ').map(function(v){return +v;});
var i=0;
var cnto=0,cnte=0;
while(i<n) {
    if(num[i]%2==1)
        cnto=cnto+1;
    else
        cnte=cnte+1;
    i++;
}
var ans=0;
if(cnto<cnte)
    ans=cnto;
else
    ans=cnte+Math.floor((cnto-cnte)/3);
print(ans);


var n = readline();
var arr = readline().split(" ");

var nc = 0;

for(var i = 0; i < n; i++){
    nc += (arr[i] % 2 == 1);
}

var c = n - nc;
var t = nc - c;
if (t <= 0)
{
    print(nc);
}
else
{
    print(c + Math.floor(t / 3));
}


var n = readline();
var arr = readline().split();

var nc = 0;

for(var i = 0; i < n; i++){
    nc += (arr[i] % 2 == 1);
}

var c = n - nc;
var t = nc - c;
if (t <= 0)
{
    print(nc);
}
else
{
    print(c + Math.floor(t / 3));
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=100005;
int a[N],n,cnt;
int main()
{
	scanf("%d",&n);
	int x1,x2;x1=x2=0;
	for(int i=1;i<=n;i++)
	{
		int t;
		scanf("%d",&t);
		t%=2;
		if(t)x1++;
		else x2++;
	}
	int ans=0;
	if(x1>x2)ans=x2+(x1-x2)/3;
	else ans=x1;
	printf("%d\n",ans);
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    int cnt1=0;
    int cnt2=0;
    for (int i=0;i<n;i++){
        int a;
        cin>>a;
        if (a%2==0){
            cnt1++;
        }else{
            cnt2++;
        }
    }
    if (cnt2==0){
        cout<<0;
        return 0;
    }
    if (cnt1>=cnt2){
        cout<<cnt2;
        return 0;
    }else{
        cout<<cnt1+(cnt2-cnt1)/3;
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    int cnt1=0;
    int cnt2=0;
    for (int i=0;i<n;i++){
        int a;
        cin>>a;
        if (a%2==0){
            cnt1++;
        }else{
            cnt2++;
        }
    }
    if (cnt1>=cnt2){
        cout<<cnt2;
        return 0;
    }else{
        cout<<cnt1+(cnt2-cnt1)/2;
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    int cnt1=0;
    int cnt2=0;
    for (int i=0;i<n;i++){
        int a;
        cin>>a;
        if (a%2==0){
            cnt1++;
        }else{
            cnt2++;
        }
    }
    int ans=(cnt1);
    cnt2=max(0,cnt2-cnt1);
    ans+=cnt2/3;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    int cnt1=0;
    int cnt2=0;
    for (int i=0;i<n;i++){
        int a;
        cin>>a;
        if (a%2==0){
            cnt1++;
        }else{
            cnt2++;
        }
    }
    if (cnt2==0){
        cout<<0;
    }
    if (cnt1>=cnt2){
        cout<<cnt2;
        return 0;
    }else{
        cout<<cnt1+(cnt2-cnt1)/2;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int even=0,odd=0;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x%2==0)
            even++;
        else
            odd++;
    }
    int minim=min(even,odd);
    int ans=minim;
    odd-=minim;
    ans+=odd/3;
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int even=0,odd=0;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x%2==0)
            even++;
        else
            odd++;
    }
    int minim=min(even,odd);
    int ans=minim;
    even-=minim;
    ans+=even/3;
    cout<<ans<<endl;
    return 0;
}


using namespace std;
#include "bits/stdc++.h"
#define el "\n"

int N, evn, odd;

int main() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
    cin >> N;
    for(int i = 1, a; i <= N; i++) {
        cin >> a;
        if(a & 1) odd++;
        else evn++;
    } if(evn > odd) cout << odd << el;
    else cout << (evn + (odd - evn) / 2) << el;
}


using namespace std;
#include "bits/stdc++.h"
#define el "\n"

int N, evn, odd;

int main() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
    cin >> N;
    for(int i = 1, a; i <= N; i++) {
        cin >> a;
        if(a & 1) odd++;
        else evn++;
    } cout << min(evn, odd) << el;
}


using namespace std;
#include "bits/stdc++.h"
#define el "\n"

int N, evn, odd;

int main() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
    cin >> N;
    for(int i = 1, a; i <= N; i++) {
        cin >> a;
        if(a & 1) odd++;
        else evn++;
    } if(evn > odd) cout << odd << el;
    else cout << (evn + (odd - evn) / 3) << el;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define inf 1000000000000000000
#define iinf -1000000000000000000
#define __   ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define mod 1000000007
#define base 1949313259
#define en '\n'

ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }

ll ar[]={0,0,1,-1};
ll br[]={1,-1,0,0};

ll bigmod(ll n,ll pow){
if(pow==0) return 1;
if(pow==1) return n%mod;

ll ans=bigmod(n,pow/2);
ans=(ans*ans)%mod;

if(pow%2==1){ans=(ans*n)%mod;}
return ans%mod;
}

ll fact[1000005];

ll nCr(ll n,ll r){

ll ans=fact[n];
ans=(ans*bigmod(fact[r],mod-2))%mod;
ans=(ans*bigmod(fact[n-r],mod-2))%mod;
return ans;
}

string s,s1,s2;
ll n,m;
ll arr[500010];
ll brr[500010];
vector<ll>v,v1;

map<ll,ll>mp;
ll vis[500005];

int main()
{__
        ll i,j,a,b,c,d,e,f,g,x,y,z,t,k,l,r;
        fact[0]=1;

      //  for(i=1;i<=1000000;i++) fact[i]=(fact[i-1]*i)%mod;
        ll ans=0,sum=0,temp;
        cin>>n;
        a=0;
        b=0;
        for(i=1;i<=n;i++){
            cin>>c;
            if(c%2==1) a++;
            else b++;
        }

        ans=min(a,b);
        a-=ans;
        b-=ans;
        if(a>0) ans+=a/3;
        cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
using namespace std;

signed main(){
	fast;
	int n; cin>>n;

	int arr[n], od=0, ev=0;
	for(int i=0; i<n; i++){
		cin>>arr[i];

		if(arr[i]%2==0) ev++;
		else od++;
	}

	if(od<=ev){
		cout<<od;
	}

	else{
		int ans=ev;
		od=od-ev;

		ans+=od/3;

		cout<<ans;
	}

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure
typedef tree<int, null_type,
			less_equal<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	indexed_set;
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 200009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll>
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/

void solve(){
	ll n;
	cin>>n;
	vi a(n);
	rep(i,0,n) cin>>a[i];
	ll odd=0,even=0;
	rep(i,0,n){
		if(a[i]%2==0) even++;
		else odd++;
	}
	ll ans=0;
	if(even>=odd){
		ans+=odd;
		even-=odd;
		odd=0;
	} else{
		ans+=even;
		odd-=even;
		even=0;
		ans+=odd/3;
	}
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


#include <bits/stdc++.h>

using namespace std;

int main(){

    int n, x, par = 0, impar = 0;

    cin >> n;

    for (int i = 0; i < n; i++){
        cin >> x;
        if (x%2) impar++;
        else par++;
    }

    if (par <= impar){
        int total = par;
        total += (impar - par) / 3;
        cout << total << endl;
    }else{
        cout << impar << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define maxn 500000
#define ll long long
ll b[maxn];
int a[maxn];
int main()
{
 ll n;
 map<int,int>m1,m2;
 cin>>n;
 for(ll i=0;i<n;i++)
 {
     ll x;
     cin>>x;
     if(x%2==0)
        m1[x]++;
     else
        m2[x]++;
 }
 if(m1.size()>m2.size())
 {
     cout<<m2.size()<<endl;
 }
 else if(m1.size()==m2.size())
      cout<<m1.size()<<endl;
      else
      {
          ll p=m2.size()-m1.size();
          p=p%3;
          p+=m1.size();
          cout<<p<<endl;
      }

}


#include<bits/stdc++.h>
using namespace std;
#define maxn 500000
#define ll long long
ll b[maxn];
int a[maxn];
int main()
{
 ll n;
 map<int,int>m1,m2;
 cin>>n;
 for(ll i=0;i<n;i++)
 {
     ll x;
     cin>>x;
     if(x%2==0)
        m1[x]++;
     else
        m2[x]++;
 }
 if(m1.size()>m2.size())
 {
     cout<<m2.size()<<endl;
 }
 else if(m1.size()==m2.size())
      cout<<m1.size()<<endl;
      else
      {
          ll p=m2.size()-m1.size();
          p=p/3;
          p+=m1.size();
          cout<<p<<endl;
      }

}


#include<bits/stdc++.h>
using namespace std;

#define io              ios_base::sync_with_stdio(false),cin.tie(NULL);
#define ll              long long
#define vi              vector<int>
#define pii             pair<int, int>
#define vii             vector<pii>
#define mii             map<int, int>

#define pb              push_back
#define ff              first
#define ss              second
#define sz              size()
#define all(a)          a.begin(), a.end()
#define mem(a, b)       memset(a, b, sizeof(a))
#define mod             1000000007
#define inf             1e9

int main()
{
    int n,v,odd=0,even,ans;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> v;
        if(v & 1)
            odd++;
    }
    even = n-odd;
    ans = min(odd,even);
    odd-=ans;
    ans+=odd/3;
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N  = 210;
vector<int>G[N<<1];

/******2-SAT判定*************************/
int tim,num;
int low[N<<1], dfn[N<<1], bel[N<<1];
bool inst[N<<1], vis[N<<1];
stack<int>st;
void tarjan(int u)
{
    vis[u] = 1;
    low[u] = dfn[u] = ++tim;
    st.push(u), inst[u] = 1;
    for(int i=0; i<G[u].size(); i++)
    {
        int v = G[u][i];
        if(!vis[v]) {
            tarjan(v);
            low[u] = min(low[u], low[v]);
        }
        else if(inst[v])
            low[u] = min(low[u], dfn[v]);
    }
    if(low[u] == dfn[u]){
        num++; int j;
        do {
            j = st.top(), st.pop();
            bel[j] = num;
            inst[j] = 0;
        } while(j!=u);
    }
}
bool judge(int n)
{
    tim = num = 0;
    memset(vis,0,sizeof(vis));
    memset(inst, 0, sizeof(inst));
    for(int i=2; i<=(n<<1|1); i++)
        if(!vis[i]) tarjan(i);
    for(int i=2; i<=(n<<1); i+=2)
        if(bel[i] == bel[i+1]) return false;
    return true;
}
/*****--------------------------------------------------------*/

char str[27];
char s[N], ans[N], tmp[N];
int w['z'+2];
char get(int pos, char c)
{
    for(int i=pos+1; str[i]!='\0'; i++)
        if(str[i] == c) return 'a'+i;
    return -1;
}
queue<int>q;
int main()
{
    int i,j,k,m,n;
    while(scanf("%s",str) == 1) {
        int len = strlen(str);
        for(i=0; i<len; i++) w[i+'a'] = str[i]=='V' ? 0 : 1;
        scanf("%d %d",&n,&m);
        for(i=2; i<(N<<1); i++) G[i].clear();
        char s1[2],s2[2];
        int a, b;
        while(m--)
        {
            scanf("%d %s %d %s",&a, s1, &b, s2);
            a = a<<1|(s1[0]!='V'), b = b<<1|(s2[0]!='V');
            G[a].push_back(b);
            G[b^1].push_back(a^1);
        }
        scanf("%s",s+1);
        if(!judge(n)) { puts("-1"); continue; }
        bool OK = false;;
        tmp[0] = -1;
        for(int pos=n+1; pos>=1; pos--)///枚举第一个比s串大的位置
        {
            //printf("pos = %d\n",pos);
            for(int a=pos<<1; a<=(pos<<1|1); a++)///枚举pos位是'V' or 'C'
            {
                bool ok = true;
                //printf("pos 为 %c\n",a&1 ? 'C' : 'V');
                strcpy(ans+1, s+1);
                memset(vis,0,sizeof(vis));
                if(pos <= n) {
                    char tp = get(s[pos]-'a', (a&1)? 'C' : 'V');
                    if(tp == -1) continue;
                    ans[pos] = tp;
                    //printf("ans[pos] = %c\n",tp);
                }
                for(i=pos+1; i<=n; i++) ans[i] = 'a';///贪心
                for(i=1; i<=n&&ok; i++) ///利用规则进行变换
                {
                    //printf("id = %d\n",i);
                    int a = i<<1|w[ans[i]];
                    if(vis[a]) continue;
                    vis[a] = 1;
                    while(!q.empty()) q.pop();
                    q.push(a);
                    while(!q.empty())
                    {
                        a = q.front(); q.pop();
                        //printf("a = %d\n",a);
                        if(vis[a^1]) {ok = false; break;}
                        ///pos以前的位置不能变
                        if(a/2 <= pos && w[ans[a/2]] != (a&1)) {ok = false; break;}
                        if(a/2 > pos) {
                            char tp = get(-1,a&1 ? 'C' : 'V');
                            if(tp == -1) {ok = false; break;}
                            ans[a/2] = tp;
                            //printf("ans[%d] = %c\n",a/2, tp);
                        }
                        for(j=0; j<G[a].size(); j++)
                        {
                            //printf("G[%d][%d] = %d\n",a,j,G[a][j]);
                            if(!vis[G[a][j]])
                                vis[G[a][j]] = 1,
                                q.push(G[a][j]);
                        }

                    }
                }
                if(!ok) continue;
                OK = true;
                ans[n+1] = 0;
                if(tmp[0] == -1) strcpy(tmp+1,ans+1);
                else if(strcmp(ans+1, tmp+1) < 0) strcpy(tmp+1, ans+1);
            }
            if(OK) break;
        }
        OK ? puts(tmp+1) :puts("-1");
    }
    return 0;
}
/**
VC
2 1
1 V 2 C
aa

VC
2 1
1 C 2 V
bb

VCC
4 3
1 C 2 V
2 C 3 V
3 V 4 V
abac

*/


#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N  = 210;
vector<int>G[N<<1];

/******2-SAT判定*************************/
int tim,num;
int low[N<<1], dfn[N<<1], vis[N<<1], bel[N<<1];
bool inst[N<<1];
stack<int>st;
void tarjan(int u)
{
    vis[u] = 1;
    low[u] = dfn[u] = ++tim;
    st.push(u), inst[u] = 1;
    for(int i=0; i<G[u].size(); i++)
    {
        int v = G[u][i];
        if(!vis[v]) {
            tarjan(v);
            low[u] = min(low[u], low[v]);
        }
        else if(inst[v])
            low[u] = min(low[u], dfn[v]);
    }
    if(low[u] == dfn[u]){
        num++; int j;
        do {
            j = st.top(), st.pop();
            bel[j] = num;
            inst[j] = 0;
        } while(j!=u);
    }
}
bool judge(int n)
{
    tim = num = 0;
    memset(vis,0,sizeof(vis));
    memset(inst, 0, sizeof(inst));
    for(int i=2; i<=(n<<1|1); i++)
        if(!vis[i]) tarjan(i);
    for(int i=2; i<=(n<<1); i+=2)
        if(bel[i] == bel[i+1]) return false;
    return true;
}
/*****--------------------------------------------------------*/

char str[27];
char s[N], ans[N], tmp[N];
int w[27];
char get(int pos, char c)
{
    for(int i=pos+1; str[i]; i++)
        if(str[i] == c) return 'a'+i;
    return -1;
}
queue<int>q;
int main()
{
    int i,j,k,m,n;
    while(scanf("%s",str) == 1) {
        int len = strlen(str);
        for(i=0; i<len; i++) w[i+'a'] = str[i]=='V' ? 0 : 1;
        scanf("%d %d",&n,&m);
        for(i=2; i<N<<1; i++) G[i].clear();
        char s1[2],s2[2];
        int a, b;
        while(m--)
        {
            scanf("%d %s %d %s",&a, s1, &b, s2);
            a = a<<1|(s1[0]!='V'), b = b<<1|(s2[0]!='V');
            G[a].push_back(b);
            G[b^1].push_back(a^1);
        }
        scanf("%s",s+1);
        if(!judge(n)) { puts("-1"); continue; }
        bool OK = false;;
        tmp[0] = -1;
        for(int pos=n+1; pos>=1; pos--)///枚举第一个比s串大的位置
        {
            //printf("pos = %d\n",pos);
            for(int a=pos<<1; a<=(pos<<1|1); a++)///枚举pos位是'V' or 'C'
            {
                bool ok = true;
                //printf("pos 为 %c\n",a&1 ? 'C' : 'V');
                strcpy(ans+1,s+1);
                memset(vis,0,sizeof(vis));
                if(pos <= n) {
                    char tp = get(s[pos]-'a', (a&1)? 'C' : 'V');
                    if(tp == -1) continue;
                    ans[pos] = tp;
                    //printf("ans[pos] = %c\n",tp);
                }
                for(i=pos+1; i<=n; i++) ans[i] = 'a';///贪心
                for(i=1; i<=n&&ok; i++) ///利用规则进行变换
                {
                    //printf("id = %d\n",i);
                    int a = i<<1|w[ans[i]];
                    if(vis[a]) continue;
                    vis[a] = 1;
                    while(!q.empty()) q.pop();
                    q.push(a);
                    while(!q.empty())
                    {
                        a = q.front(); q.pop();
                        //printf("a = %d\n",a);
                        if(vis[a^1]) {ok = false; break;}
                        ///pos以前的位置不能变
                        if(a/2 <= pos && w[ans[a/2]] != (a&1)) {ok = false; break;}
                        if(a/2 > pos) {
                            char tp = get(-1,a&1 ? 'C' : 'V');
                            if(tp == -1) {ok = false; break;}
                            ans[a/2] = tp;
                            //printf("ans[%d] = %c\n",a/2, tp);
                        }
                        for(j=0; j<G[a].size(); j++)
                        {
                            //printf("G[%d][%d] = %d\n",a,j,G[a][j]);
                            if(!vis[G[a][j]])
                                vis[G[a][j]] = 1,
                                q.push(G[a][j]);
                        }

                    }
                }
                if(!ok) continue;
                OK = true;
                ans[n+1] = 0;
                if(tmp[0] == -1) strcpy(tmp+1,ans+1);
                else if(strcmp(ans+1, tmp+1) < 0) strcpy(tmp+1, ans+1);
            }
            if(OK) break;
        }
        OK ? puts(tmp+1) :puts("-1");
    }
    return 0;
}
/**
VC
2 1
1 V 2 C
aa

VC
2 1
1 C 2 V
bb

VCC
4 3
1 C 2 V
2 C 3 V
3 V 4 V
abac

*/


#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N  = 210;
vector<int>G[N<<1];

/******2-SAT判定*************************/
int tim,num;
int low[N<<1], dfn[N<<1], bel[N<<1];
bool inst[N<<1], vis[N<<1];
stack<int>st;
void tarjan(int u)
{
    vis[u] = 1;
    low[u] = dfn[u] = ++tim;
    st.push(u), inst[u] = 1;
    for(int i=0; i<G[u].size(); i++)
    {
        int v = G[u][i];
        if(!vis[v]) {
            tarjan(v);
            low[u] = min(low[u], low[v]);
        }
        else if(inst[v])
            low[u] = min(low[u], dfn[v]);
    }
    if(low[u] == dfn[u]){
        num++; int j;
        do {
            j = st.top(), st.pop();
            bel[j] = num;
            inst[j] = 0;
        } while(j!=u);
    }
}
bool judge(int n)
{
    tim = num = 0;
    memset(vis,0,sizeof(vis));
    memset(inst, 0, sizeof(inst));
    for(int i=2; i<=(n<<1|1); i++)
        if(!vis[i]) tarjan(i);
    for(int i=2; i<=(n<<1); i+=2)
        if(bel[i] == bel[i+1]) return false;
    return true;
}
/*****--------------------------------------------------------*/

char str[27];
char s[N], ans[N], tmp[N];
int w['z'+2];
char get(int pos, char c)
{
    for(int i=pos+1; str[i]!='\0'; i++)
        if(str[i] == c) return 'a'+i;
    return -1;
}
queue<int>q;
int main()
{
    int i,j,k,m,n;
    while(scanf("%s",str) == 1) {
        int len = strlen(str);
        for(i=0; i<len; i++) w[i+'a'] = str[i]=='V' ? 0 : 1;
        scanf("%d %d",&n,&m);
        for(i=2; i<(N<<1); i++) G[i].clear();
        char s1[2],s2[2];
        int a, b;
        while(m--)
        {
            scanf("%d %s %d %s",&a, s1, &b, s2);
            a = a<<1|(s1[0]!='V'), b = b<<1|(s2[0]!='V');
            G[a].push_back(b);
            G[b^1].push_back(a^1);
        }
        scanf("%s",s+1);
        if(!judge(n)) { puts("-1"); continue; }
        bool OK = false;;
        tmp[1] = -1;
        for(int pos=n+1; pos>=1; pos--)///枚举第一个比s串大的位置
        {
            //printf("pos = %d\n",pos);
            for(int a=pos<<1; a<=(pos<<1|1); a++)///枚举pos位是'V' or 'C'
            {
                bool ok = true;
                //printf("pos 为 %c\n",a&1 ? 'C' : 'V');
                strcpy(ans+1, s+1);
                memset(vis,0,sizeof(vis));
                if(pos <= n) {
                    char tp = get(s[pos]-'a', (a&1)? 'C' : 'V');
                    if(tp == -1) continue;
                    ans[pos] = tp;
                    //printf("ans[pos] = %c\n",tp);
                }
                for(i=pos+1; i<=n; i++) ans[i] = 'a';///贪心
                for(i=1; i<=n&&ok; i++) ///利用规则进行变换
                {
                    //printf("id = %d\n",i);
                    int a = i<<1|w[ans[i]];
                    if(vis[a]) continue;
                    vis[a] = 1;
                    while(!q.empty()) q.pop();
                    q.push(a);
                    while(!q.empty())
                    {
                        a = q.front(); q.pop();
                        //printf("a = %d\n",a);
                        if(vis[a^1]) {ok = false; break;}
                        ///pos以前的位置不能变
                        if(a/2 <= pos && w[ans[a/2]] != (a&1)) {ok = false; break;}
                        if(a/2 > pos) {
                            char tp = get(-1,a&1 ? 'C' : 'V');
                            if(tp == -1) {ok = false; break;}
                            ans[a/2] = tp;
                            //printf("ans[%d] = %c\n",a/2, tp);
                        }
                        for(j=0; j<G[a].size(); j++)
                        {
                            //printf("G[%d][%d] = %d\n",a,j,G[a][j]);
                            if(!vis[G[a][j]])
                                vis[G[a][j]] = 1,
                                q.push(G[a][j]);
                        }

                    }
                }
                if(!ok) continue;
                OK = true;
                ans[n+1] = 0;
                if(tmp[1] == -1) strcpy(tmp+1,ans+1);
                else if(strcmp(ans+1, tmp+1) < 0) strcpy(tmp+1, ans+1);
            }
            if(OK) break;
        }
        OK ? puts(tmp+1) :puts("-1");
    }
    return 0;
}
/**
VC
2 0
aa

/**
VC
2 1
1 V 2 C
aa

VC
2 1
1 C 2 V
bb

VCC
4 3
1 C 2 V
2 C 3 V
3 V 4 V
abac

*/


#include <cstdio>
#include <algorithm>
#include <cstring>
#define rep(i, lo, hi) for(int i = (lo); i < (hi); i++)
using namespace std;

const int MAXN = 500;

int g[MAXN][MAXN], c[2], N, M, L;
char a[MAXN], s[MAXN], r[MAXN];

int t(char x) {
	return x == 'C';
}

int ok(int i, int j) {
	i = 2*i + t(a[r[i]-'a']), j = 2*j + t(a[r[j]-'a']);
	return !g[i][j^1] && !g[j][i^1];
}

int f(int i, int gr) {
	if(i == N) {
		puts(r);
		exit(0);
	}
	rep(x, gr? 'a' : s[i], 'a' + L) {
		r[i] = x;
		rep(j, 0, i+1) if(!ok(j, i))
			goto end;
		f(i+1, gr || r[i] > s[i]);
		end:;
	}
	return 0;
}

int main() {
	//freopen("in.txt", "r", stdin);
	scanf("%s%d%d\n", a, &N, &M);
	L = strlen(a);
	rep(i, 0, L)
		c[t(a[i])] = 1;
	if(!c[0] || !c[1]) rep(i, 0, N)
		g[2*i+c[0]][2*i+c[0]^1] = 1;

	rep(i, 0, M) {
		int x, y; char p[2], q[2];
		scanf("%d %s %d %s", &x, p, &y, q);
		x = 2*(x-1) + t(p[0]), y = 2*(y-1) + t(q[0]);
		g[x][y] = g[y^1][x^1] = 1;
	}
	scanf("%s", s);

	rep(k, 0, 2*N) rep(i, 0, 2*N) rep(j, 0, 2*N)
		g[i][j] |= g[i][k] && g[k][j];

	rep(i, 0, 2*N) if(g[i][i^1] && g[i^1][i]) {
		puts("-1");
		return 0;
	}

	f(0, 0);
	puts("-1");
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define _int64 long long

char s1[10];
char s2[10];
char s[1000];
char ss[1000];
int a[500][500];

int minc,minv;
int n;
char now[500];
vector<int> q;
int used[500];

string solve(int pos)
{
  int i,j,k,x;
  for (i=0;i<q.size();i++)
  {
    x=q[i];
    //cout<<"i,x,pos: "<<pos<<" "<<i<<" "<<x<<endl;
    for (j=0;j<n+n;j++)
    {
      if ((a[x][j]==1)&&(used[j]==0))
      {
        used[j]=1;
        q.push_back(j);
      }
    }
  }
  for (i=0;i<n;i++)
    if ((used[i+i]==1)&&(used[i+i+1]==1)) return "{";
  //cout<<"good."<<endl;
  char ret[1000];
  for (i=pos+1;i<n;i++)
  {
    if ((used[i+i]==1)&&(used[i+i+1]==1)) return "{";
    if ((used[i+i]==0)&&(used[i+i+1]==0))
    {
      if (minc<minv)
      {
        used[i+i]=1;
        q.push_back(i+i);
      }
      else
      {
        used[i+i+1]=1;
        q.push_back(i+i+1);
      }
      for (j=q.size()-1;j<q.size();j++)
      {
        x=q[j];
        for (k=0;k<n+n;k++)
        {
          if ((a[x][k]==1)&&(used[k]==0))
          {
            used[k]=1;
            q.push_back(k);
          }
        }
      }
    }
    if (used[i+i]==1) ret[i-pos-1]='a'+minc;
    else ret[i-pos-1]='a'+minv;
  }
  ret[n-pos-1]='\0';
  return ret;
}

int main()
{
  int i,j,nn,l,allc,allv,bc,bv,x,y,x1,y1,ind,ind1,indc,indv,m,k;
  string tmp,ans;
  scanf("%s",ss);
  nn=strlen(ss);
  minc=-1;minv=-1;
  for (i=0;i<nn;i++)
    if (ss[i]=='C')
    {
      minc=i;
      break;
    }
  for (i=0;i<nn;i++)
    if (ss[i]=='V')
    {
      minv=i;
      break;
    }
  allc=1;
  allv=1;
  //cout<<nn<<endl;
  for (i=0;i<nn;i++)
  {
    if (ss[i]=='V') allc=0;
    if (ss[i]=='C') allv=0;
  }
  //cout<<allc<<" "<<allv<<endl;
  bc=1;bv=1;
  scanf("%d%d", &n,&m);
  memset(a,0,sizeof(a));
  for (i=0;i<n+n;i++)
    a[i][i]=1;
  for (i=0;i<m;i++)
  {
    //cout<<i<<endl;
    scanf("%d%s%d%s",&x,s1,&y,s2);
    x--;y--;
    if (s1[0]=='C') x1=0;
    else x1=1;
    if (s2[0]=='C') y1=0;
    else y1=1;
    if ((x1==0)&&(y1==1)) bc=0;
    if ((x1==1)&&(y1==0)) bv=0;
    a[x*2+x1][y*2+y1]=1;
    a[y*2+1-y1][x*2+1-x1]=1;
  }
  //cout<<allc<<" "<<allv<<endl;
  for (k=0;k<n+n;k++)
    for (i=0;i<n+n;i++)
      for (j=0;j<n+n;j++)
        if ((a[i][k]==1)&&(a[k][j]==1)) a[i][j]=1;
/*  for (i=0;i<n;i++)
    if ((a[i+i][i+i+1]==1)||(a[i+i+1][i+i]==1))
    {
      printf("-1\n");
      return 0;
    }
*/
  scanf("%s",s);
  l=strlen(s);
  //cout<<allc<<" "<<allv<<endl;
  if (allc==1)
  {
    if (bc==1)
    {
      printf("%s\n",s);
      return 0;
    }
    else
    {
      printf("-1\n");
      return 0;
    }
  }
  if (allv==1)
  {
    if (bv==1)
    {
      printf("%s\n",s);
      return 0;
    }
    else
    {
      printf("-1\n");
      return 0;
    }
  }
  //cout<<"qqq"<<endl;
  ans="{";
  for (i=0;i<l;i++)
  {
    //cout<<"i: "<<i<<endl;
    ind=s[i]-'a'+1;
    indc=-1;
    for (j=ind;j<nn;j++)
      if (ss[j]=='C')
      {
        indc=j;break;
      }
    indv=-1;
    for (j=ind;j<nn;j++)
      if (ss[j]=='V')
      {
        indv=j;break;
      }
    //cout<<indc<<" "<<indv<<endl;
    if (indc!=-1)
    {
      q.clear();
      memset(used,0,sizeof(used));
      for (j=0;j<i;j++)
      {
        x=j;
        if (ss[s[j]-'a']=='C') x1=0;
        else x1=1;
        q.push_back(x*2+x1);
        used[x*2+x1]=1;
        now[j]=s[j];
      }
      q.push_back(i*2);
      used[i*2]=1;
      now[i]='a'+indc;
      now[i+1]='\0';
      tmp=solve(i);
      if (tmp!="{")
      {
        tmp=now+tmp;
        if (tmp<ans) ans=tmp;
        //cout<<"c: "<<i<<" "<<tmp<<endl;
      }
    }
    if (indv!=-1)
    {
      q.clear();
      memset(used,0,sizeof(used));
      for (j=0;j<i;j++)
      {
        x=j;
        if (ss[s[j]-'a']=='C') x1=0;
        else x1=1;
        q.push_back(x*2+x1);
        used[x*2+x1]=1;
        now[j]=s[j];
      }
      q.push_back(i*2+1);
      used[i*2+1]=1;
      now[i]='a'+indv;
      now[i+1]='\0';
      tmp=solve(i);
      if (tmp!="{")
      {
        tmp=now+tmp;
        if (tmp<ans) ans=tmp;
        //cout<<"v: "<<i<<" "<<tmp<<endl;
      }
    }
  }
  q.clear();
  memset(used,0,sizeof(used));
  for (j=0;j<l;j++)
  {
    x=j;
    if (ss[s[j]-'a']=='C') x1=0;
    else x1=1;
    q.push_back(x*2+x1);
    used[x*2+x1]=1;
    now[j]=s[j];
  }
  now[l]='\0';
  tmp=solve(l-1);
  if (tmp!="{")
  {
    tmp=now+tmp;
    if (tmp<ans) ans=tmp;
  }
  if (ans=="{") printf("-1\n");
  else printf("%s\n",ans.c_str());
  return 0;
}


#include <stdio.h>
#include <string.h>
int n,m,i,j,k,kx,ky,x,y,e,b[555];
char a[555],s[555],tx[22],ty[22],cur,q;
bool g[555][555],can[22];
int gc(char c) { return int(c=='C'); }
bool gg(int i, int j) { return g[i][j^1] || g[j][i^1]; }
bool check(int e, char st) {
  for (int k=0; k<2; k++) {
    can[k]=true;
    b[e]=e*2+k;
    for (int i=0; i<=e; i++) if (gg(b[e],b[i])) { can[k]=false; break; }
  }
  if (!can[0] && !can[1]) return false;
  for (s[e]=st; s[e]<q && !can[gc(a[s[e]-'a'])]; s[e]++);
  if (s[e]>=q) return false;
  b[e]=e*2+gc(a[s[e]-'a']);
  return true;
}
int main() {
  scanf("%s",a);
  q='a'+strlen(a);
  scanf("%d%d",&n,&m);
  for (i=0; i<m; i++) {
    scanf("%d",&x); x--;
    scanf("%s",tx); kx=gc(tx[0]);
    scanf("%d",&y); y--;
    scanf("%s",ty); ky=gc(ty[0]);
    g[x*2+kx][y*2+ky]=true;
    g[y*2+1-ky][x*2+1-kx]=true;
  }
  scanf("%s",s);
  for (k=0; k<2*n; k++) for (i=0; i<2*n; i++) for (j=0; j<2*n; j++) g[i][j]|=(g[i][k] && g[k][j]);
  for (e=0; e<n; e++) b[e]=e*2+gc(a[s[e]-'a']);
  for (e=0; e<n; e++) {
    for (i=0; i<=e; i++) if (gg(b[e],b[i])) break;
    if (i<=e) break;
  }
  if (e>=n) {
    puts(s);
    return 0;
  }
  for (; e>=0; e--) {
    if (!check(e,s[e]+1)) continue;
    for (j=e+1; j<n; j++) if (!check(j,'a')) { puts("-1"); return 0; }
    puts(s);
    return 0;
  }
  if (e<0) puts("-1");
  return 0;
}