#int(input()) #map(int, input().split()) #list(map(int, input().split())) X = int(input()) p = [1] * (X + 10) for i in range(2, X+1): if p[i] != 1: continue for j in range(1, X+1): if i * j > X: break p[i*j] = i # print(p) from collections import Counter d = [0] * (X + 1) for i in range(2, X): v = [] t = i while t != 1: v.append(p[t]) t //= p[t] c = list(Counter(v).values()) a = 1 for x in c: a *= (x + 1) d[i] = i - a m = X+1 for i in range(1, X): m = min(m, abs(d[i] - d[X-i])) for i in range(1, X): if abs(d[i] - d[X-i]) == m: print(i, X-i)