import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		long count = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0 && i % 15 != 0) {
				count += i;
			}
		}
		System.out.println(count);
		kb.close();
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		long count = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0 && i % 15 != 0) {
				count += i;
			}
		}
		System.out.println(count);
		kb.close();
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		long count = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0 && i % 15 != 0) {
				count += i;
			}
		}
		System.out.println(count);
		kb.close();
	} main {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		long count = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0 && i % 15 != 0) {
				count += i;
			}
		}
		System.out.println(count);
		kb.close();
	} Scanner kb = new Scanner(System.in); kb new Scanner(System.in) int n = kb.nextInt(); n kb.nextInt() kb.nextInt kb long count = 0; count 0 for (int i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0 && i % 15 != 0) {
				count += i;
			}
		} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
			if (i % 3 != 0 && i % 5 != 0 && i % 15 != 0) {
				count += i;
			}
		} {
			if (i % 3 != 0 && i % 5 != 0 && i % 15 != 0) {
				count += i;
			}
		} if (i % 3 != 0 && i % 5 != 0 && i % 15 != 0) {
				count += i;
			} i % 3 != 0 && i % 5 != 0 && i % 15 != 0 i % 3 != 0 && i % 5 != 0 && i % 15 != 0 i % 3 != 0 i % 3 i 3 0 i % 5 != 0 i % 5 i 5 0 i % 15 != 0 i % 15 i 15 0 {
				count += i;
			} count += i count i System.out.println(count) System.out.println System.out System System.out count kb.close() kb.close kb String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		long count = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0 && i % 15 != 0) {
				count += i;
			}
		}
		System.out.println(count);
		kb.close();
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		long count = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0 && i % 15 != 0) {
				count += i;
			}
		}
		System.out.println(count);
		kb.close();
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		long count = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 3 != 0 && i % 5 != 0 && i % 15 != 0) {
				count += i;
			}
		}
		System.out.println(count);
		kb.close();
	}

}
