import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		long n 	= Long.parseLong(scanner.nextLine());
		long ans = 0;

		for(long j = 1; j < n + 1; j++) {

			if(j % 3 != 0 && j % 5 != 0) {

				ans += j;

			}

		}

		System.out.println(ans);



	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		long n 	= Long.parseLong(scanner.nextLine());
		long ans = 0;

		for(long j = 1; j < n + 1; j++) {

			if(j % 3 != 0 && j % 5 != 0) {

				ans += j;

			}

		}

		System.out.println(ans);



	}
} Main public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		long n 	= Long.parseLong(scanner.nextLine());
		long ans = 0;

		for(long j = 1; j < n + 1; j++) {

			if(j % 3 != 0 && j % 5 != 0) {

				ans += j;

			}

		}

		System.out.println(ans);



	} main {

		Scanner scanner = new Scanner(System.in);

		long n 	= Long.parseLong(scanner.nextLine());
		long ans = 0;

		for(long j = 1; j < n + 1; j++) {

			if(j % 3 != 0 && j % 5 != 0) {

				ans += j;

			}

		}

		System.out.println(ans);



	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) long n 	= Long.parseLong(scanner.nextLine()); n Long.parseLong(scanner.nextLine()) Long.parseLong Long scanner.nextLine() scanner.nextLine scanner long ans = 0; ans 0 for(long j = 1; j < n + 1; j++) {

			if(j % 3 != 0 && j % 5 != 0) {

				ans += j;

			}

		} long j = 1; long j = 1; j 1 j < n + 1 j n + 1 n 1 j++ j++ j {

			if(j % 3 != 0 && j % 5 != 0) {

				ans += j;

			}

		} {

			if(j % 3 != 0 && j % 5 != 0) {

				ans += j;

			}

		} if(j % 3 != 0 && j % 5 != 0) {

				ans += j;

			} j % 3 != 0 && j % 5 != 0 j % 3 != 0 j % 3 j 3 0 j % 5 != 0 j % 5 j 5 0 {

				ans += j;

			} ans += j ans j System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		long n 	= Long.parseLong(scanner.nextLine());
		long ans = 0;

		for(long j = 1; j < n + 1; j++) {

			if(j % 3 != 0 && j % 5 != 0) {

				ans += j;

			}

		}

		System.out.println(ans);



	}
} public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		long n 	= Long.parseLong(scanner.nextLine());
		long ans = 0;

		for(long j = 1; j < n + 1; j++) {

			if(j % 3 != 0 && j % 5 != 0) {

				ans += j;

			}

		}

		System.out.println(ans);



	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		long n 	= Long.parseLong(scanner.nextLine());
		long ans = 0;

		for(long j = 1; j < n + 1; j++) {

			if(j % 3 != 0 && j % 5 != 0) {

				ans += j;

			}

		}

		System.out.println(ans);



	}
}