#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Aug  9 00:36:39 2020

@author: manish
"""

def Q72(N):
    totient = [i for i in range(N+1)]
    for i in range(2, N+1):
        if totient[i] == i:
            for j in range(i, N+1, i):
                totient[j] -= totient[j] // i
    print(sum(totient) - totient[1])
    
if __name__ == '__main__':
    import time
    start_time = time.time()
    Q72(1_000_000)
    print("Program run time(in s): ", (time.time() - start_time)) 