import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] ans = new int[n + 1];
		long res = 0L;
		for(int i = 3; i <= n; i += 3) ans[i] = 1;
		for(int i = 5; i <= n; i += 5) ans[i] = 1;
		for(int i = 1; i <= n; i++) {
			if(ans[i] == 0) res += i;
		}
		System.out.println(res);
	}
}  import java.util.*; util.* java import java.math.*; math.* java public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] ans = new int[n + 1];
		long res = 0L;
		for(int i = 3; i <= n; i += 3) ans[i] = 1;
		for(int i = 5; i <= n; i += 5) ans[i] = 1;
		for(int i = 1; i <= n; i++) {
			if(ans[i] == 0) res += i;
		}
		System.out.println(res);
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] ans = new int[n + 1];
		long res = 0L;
		for(int i = 3; i <= n; i += 3) ans[i] = 1;
		for(int i = 5; i <= n; i += 5) ans[i] = 1;
		for(int i = 1; i <= n; i++) {
			if(ans[i] == 0) res += i;
		}
		System.out.println(res);
	} main {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] ans = new int[n + 1];
		long res = 0L;
		for(int i = 3; i <= n; i += 3) ans[i] = 1;
		for(int i = 5; i <= n; i += 5) ans[i] = 1;
		for(int i = 1; i <= n; i++) {
			if(ans[i] == 0) res += i;
		}
		System.out.println(res);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = in.nextInt(); n in.nextInt() in.nextInt in int[] ans = new int[n + 1]; ans new int[n + 1] n + 1 n 1 long res = 0L; res 0L for(int i = 3; i <= n; i += 3) ans[i] = 1; int i = 3; int i = 3; i 3 i <= n i n i += 3 i += 3 i 3 ans[i] = 1; ans[i] = 1 ans[i] ans i 1 for(int i = 5; i <= n; i += 5) ans[i] = 1; int i = 5; int i = 5; i 5 i <= n i n i += 5 i += 5 i 5 ans[i] = 1; ans[i] = 1 ans[i] ans i 1 for(int i = 1; i <= n; i++) {
			if(ans[i] == 0) res += i;
		} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
			if(ans[i] == 0) res += i;
		} {
			if(ans[i] == 0) res += i;
		} if(ans[i] == 0) res += i; ans[i] == 0 ans[i] ans i 0 res += i res i System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] ans = new int[n + 1];
		long res = 0L;
		for(int i = 3; i <= n; i += 3) ans[i] = 1;
		for(int i = 5; i <= n; i += 5) ans[i] = 1;
		for(int i = 1; i <= n; i++) {
			if(ans[i] == 0) res += i;
		}
		System.out.println(res);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] ans = new int[n + 1];
		long res = 0L;
		for(int i = 3; i <= n; i += 3) ans[i] = 1;
		for(int i = 5; i <= n; i += 5) ans[i] = 1;
		for(int i = 1; i <= n; i++) {
			if(ans[i] == 0) res += i;
		}
		System.out.println(res);
	}
} Main
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] ans = new int[n + 1];
		long res = 0L;
		for(int i = 3; i <= n; i += 3) ans[i] = 1;
		for(int i = 5; i <= n; i += 5) ans[i] = 1;
		for(int i = 1; i <= n; i++) {
			if(ans[i] == 0) res += i;
		}
		System.out.println(res);
	}
} 
