import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); boolean[] isPrime = new boolean[1263]; int[] g = new int[isPrime.length]; Arrays.fill(isPrime, true); isPrime[0] = isPrime[1] = false; int cnt = 0; for (int i = 2; i < isPrime.length; ++i) { if (!isPrime[i]) continue; for (int j = 2 * i; j < isPrime.length; j += i) { isPrime[j] = false; } if (i * i <= isPrime.length) for (int j = i; j < isPrime.length; j += i) { g[j] |= 1 << cnt; } ++cnt; } ArrayList plist = new ArrayList<>(); for (int i = 0; i < isPrime.length; ++i) { if (isPrime[i]) plist.add(i); } int N = sc.nextInt(); boolean[] vis = new boolean[N + 1]; long[] dp = new long[1 << 11]; for (int i = N; i > plist.get(10); --i) { if (!isPrime[i]) continue; long[] ndp = Arrays.copyOf(dp, dp.length); for (int j = i; j <= N; j += i) { vis[j] = true; for (int s = 0; s < 1 << 11; ++s) { if ((s & g[i]) == 0) { ndp[s | g[i]] = Math.max(ndp[s | g[i]], dp[s] + j); } } } dp = ndp; } for (int i = 2; i <= N; ++i) { if (vis[i]) continue; for (int s = 0; s < 1 << 11; ++s) { if ((s & g[i]) == 0) dp[s | g[i]] = Math.max(dp[s | g[i]], dp[s] + i); } } long ans = 0; for (long v : dp) ans = Math.max(ans, v); System.out.println(ans); } long gcd(long a, long b) { if (a > b) return gcd(b, a); if (a == 0) return b; return gcd(a, b % a); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }