// Arup Guha
// 4/19/2016
// Solution to 2016 NAIPC Problem I: Tourists

// Note: Their run-time of 4 seconds was ridiculous for this. I had very nice reasonable code that took 5.3 seconds.
//       I had to get rid of all of my objects, three of my function (inlining them into other functions),
//       change my DFS tree creation to a BFS tree creation, then switch LinkedList to ArrayDeque.
//       None of this was useful or educational...

import java.util.*;
import java.io.*;

public class i {

	public static int n;
	public static int[] depth;
	public static ArrayList<Integer>[] kids;
	public static ArrayList<Integer>[] ancestors;

	public static void main(String[] args) throws Exception {

		// Read in original input as a graph.
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(stdin.readLine().trim());
		depth = new int[n];
		kids = new ArrayList[n];
		ancestors = new ArrayList[n];
		for (int i=0; i<n; i++) {
			kids[i] = new ArrayList<Integer>();
			ancestors[i] = new ArrayList<Integer>();
		}

		for (int i=1; i<n; i++) {
			StringTokenizer tok = new StringTokenizer(stdin.readLine());
			int v1 = Integer.parseInt(tok.nextToken())-1;
			int v2 = Integer.parseInt(tok.nextToken())-1;
			kids[v1].add(v2);
			kids[v2].add(v1);
		}

		// Form our tree.
		makeTree(0, -1, 0);

		// Adds all paths from 1 quickly.
		long res = 0;
		for (int i=1; i<n; i++)
			res += (depth[i]+1);

		// Now, just loop through the rest of the paths.
		for (int i=2; i<=n; i++)
			for (int j=2*i; j<=n; j+=i)
				res += (depth[i-1] + depth[j-1] - 2*depth[lca(i-1, j-1)] + 1);

		// Final answer.
		System.out.println(res);
	}

	// Returns the lowest common ancestor of v1 and v2 in the tree.
	public static int lca(int v1, int v2) {

		// Make v1 further down than v2.
		if (depth[v1] < depth[v2]) {
			int tmp = v1;
			v1 = v2;
			v2 = tmp;
		}

		// Move v1 to same level as v2.
		if (depth[v1] != depth[v2]) v1 = hopUp(v1, depth[v1]-depth[v2]);

		// "Binary Search" the LCA using binary lifting.
		int maxjump = 1000;
		while (v1 != v2) {
			int shift = Math.min(maxjump, ancestors[v1].size()-1);
			while (shift > 0 && ancestors[v1].get(shift) == ancestors[v2].get(shift)) shift--;
			v1 = ancestors[v1].get(shift);
			v2 = ancestors[v2].get(shift);
		}
		return v1;
	}

	public static int hopUp(int node, int levels) {

		// Find smallest hop by bit.
		int shift = 0;
		int cur = node;

		// Hop until we get to the right place.
		while (levels > 0) {

			while (((1<<shift) & levels) == 0) shift++;

			// Hop up by 2^shift.
			cur = ancestors[cur].get(shift);
			levels -= (1<<shift);
			shift++;
		}

		// Ta da!
		return cur;
	}

	public static void makeTree(int root, int parent, int curDepth) {

		// Set up BFS.
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		q.offer(root);
		int[] par = new int[n];
		par[0] = -1;
		depth[root] = 0;

		// Run BFS.
		while (q.size() > 0) {

			root = q.poll();

			// Handle root - put in depth and fill in binary lifting array.
			if (par[root] != -1) {
				ancestors[root].add(par[root]);
				int i = 1, ancestor = par[root];
				while (i-1 < ancestors[ancestor].size()) {
					ancestors[root].add(ancestors[ancestor].get(i-1));
					ancestor = ancestors[ancestor].get(i-1);
					i++;
				}
			}

			// Remove the parent from the kid list.
			kids[root].remove( (Integer)par[root] );

			// Enqueue the kids.
			for (int i=0; i<kids[root].size(); i++) {
				int next = kids[root].get(i);
				q.offer(next);
				par[next] = root;
				depth[next] = depth[root]+1;
			}
		}
	}
}