import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.Closeable; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; import java.util.HashMap; import java.util.List; import java.util.Scanner; import java.util.TreeMap; public class Main { static ContestScanner in;static Writer out;public static void main(String[] args) {try{in=new ContestScanner();out=new Writer();Main solve=new Main();solve.solve(); in.close();out.flush();out.close();}catch(IOException e){e.printStackTrace();}} static void dump(int[]a){for(int i=0;i0){if((n&1)==1)r*=a;a*=a;n>>=1;}return r;} static String itob(int a,int l){return String.format("%"+l+"s",Integer.toBinaryString(a)).replace(' ','0');} static void sort(int[]a){m_sort(a,0,a.length,new int[a.length]);} static void sort(int[]a,int l){m_sort(a,0,l,new int[l]);} static void sort(int[]a,int l,int[]buf){m_sort(a,0,l,buf);} static void sort(int[]a,int s,int l,int[]buf){m_sort(a,s,l,buf);} static void m_sort(int[]a,int s,int sz,int[]b) {if(sz<7){for(int i=s;is&&a[j-1]>a[j];j--)swap(a, j, j-1);return;} m_sort(a,s,sz/2,b);m_sort(a,s+sz/2,sz-sz/2,b);int idx=s;int l=s,r=s+sz/2;final int le=s+sz/2,re=s+sz; while(la[r])b[idx++]=a[r++];else b[idx++]=a[l++];} while(rs&&a[j-1]>a[j];j--)swap(a, j, j-1);return;} m_sort(a,s,sz/2,b);m_sort(a,s+sz/2,sz-sz/2,b);int idx=s;int l=s,r=s+sz/2;final int le=s+sz/2,re=s+sz; while(la[r])b[idx++]=a[r++];else b[idx++]=a[l++];} while(rv)r=m-1;else{l=m+1;s=m;}}return s;} static int binarySearchSmallerMax(int[]a,int v,int l,int r) {int s=-1;while(l<=r){int m=(l+r)/2;if(a[m]>v)r=m-1;else{l=m+1;s=m;}}return s;} static List[]createGraph(int n) {List[]g=new List[n];for(int i=0;i();return g;} void solve() throws NumberFormatException, IOException{ final int n = in.nextInt(); LCA lca = new LCA(n); for(int i=0; i=0) sum[par]--; } node = lca.tree; // dfs(0, -1); int[] cq = new int[n*2+10]; int[] pq = new int[n*2+10]; boolean[] fq = new boolean[n*2+10]; int t = 1; pq[0] = -1; while(t>0){ final int cur = cq[--t]; final int par = pq[t]; final boolean flg = fq[t]; if(flg){ if(par>=0){ sum[par] += sum[cur]; // System.out.println("par: "+par+" ;"+(sum[par]-sum[cur])+"->"+sum[par]); } }else{ fq[t] = true; cq[t] = cur; pq[t] = par; t++; for(int v: node[cur]){ if(v==par) continue; fq[t] = false; cq[t] = v; pq[t] = cur; t++; } } } long ans = 0; for(int i=0; i[] node; int dfs(int cur, int par){ for(int v: node[cur]){ if(v==par) continue; sum[cur] += dfs(v, cur); } return sum[cur]; } } class LCA{ List[] tree; int[][] parent; int[] dep; int log, sp; final int n; int[] stc, stp, std; public LCA(int n) { tree = new List[n]; for(int i=0; i(); log = 0; int m = n; while(m>0){ log++; m >>= 1; } parent = new int[n][log]; dep = new int[n]; stc = new int[n]; stp = new int[n]; std = new int[n]; this.n = n; } void edge(int p, int c){ tree[p].add(c); } int parent(int c){ if(parent[c][0]==c) return -1; return parent[c][0]; } public void checkPar(int root){ stc[0] = stp[0] = root; std[0] = 0; sp = 1; while(sp>0){ final int cur = stc[--sp]; final int par = stp[sp]; final int d = std[sp]; dep[cur] = d; parent[cur][0] = par; for(int v: tree[cur]){ if(v==par) continue; stc[sp] = v; stp[sp] = cur; std[sp] = d+1; sp++; } } for(int i=1; idep[v]){ final int tmp = u; u = v; v = tmp; } for(int i=0, d=dep[v]-dep[u]; d>0; i++, d>>=1){ if((d&1)==1) v = parent[v][i]; } if(u==v) return u; for(int i=log-1; i>=0; i--){ if(parent[v][i]!=parent[u][i]){ v = parent[v][i]; u = parent[u][i]; } } return parent[u][0]; } } class MultiSet extends HashMap{ @Override public Integer get(Object key){return containsKey(key)?super.get(key):0;} public void add(T key,int v){put(key,get(key)+v);} public void add(T key){put(key,get(key)+1);} public void sub(T key){final int v=get(key);if(v==1)remove(key);else put(key,v-1);} public MultiSet merge(MultiSet set) {MultiSets,l;if(this.size()e:s.entrySet())l.add(e.getKey(),e.getValue());return l;} } class OrderedMultiSet extends TreeMap{ @Override public Integer get(Object key){return containsKey(key)?super.get(key):0;} public void add(T key,int v){put(key,get(key)+v);} public void add(T key){put(key,get(key)+1);} public void sub(T key){final int v=get(key);if(v==1)remove(key);else put(key,v-1);} public OrderedMultiSet merge(OrderedMultiSet set) {OrderedMultiSets,l;if(this.size(){ int a,b;final int hash;Pair(int a,int b){this.a=a;this.b=b;hash=(a<<16|a>>16)^b;} public boolean equals(Object obj){Pair o=(Pair)(obj);return a==o.a&&b==o.b;} public int hashCode(){return hash;} public int compareTo(Pair o){if(a!=o.a)return a