import java.util.Scanner;


public class Main {


	final int MOD = 1000000007;


	public static void main(String[] args) {

		long ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

		int n = sc.nextInt();
//		int k = sc.nextInt();

		//-------------------------------------------------------------------------------------

		for(int i =1; i <= n; i++) {
			if(i%3 == 0 && i%5 == 0) {
				continue;
			}
			if(i%3 == 0) {
				continue;
			}
			if(i%5 == 0) {
				continue;
			}
			ans += i;
		}


		//-------------------------------------------------------------------------------------

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {


	final int MOD = 1000000007;


	public static void main(String[] args) {

		long ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

		int n = sc.nextInt();
//		int k = sc.nextInt();

		//-------------------------------------------------------------------------------------

		for(int i =1; i <= n; i++) {
			if(i%3 == 0 && i%5 == 0) {
				continue;
			}
			if(i%3 == 0) {
				continue;
			}
			if(i%5 == 0) {
				continue;
			}
			ans += i;
		}


		//-------------------------------------------------------------------------------------

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	}
} Main final int MOD = 1000000007; MOD 1000000007 public static void main(String[] args) {

		long ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

		int n = sc.nextInt();
//		int k = sc.nextInt();

		//-------------------------------------------------------------------------------------

		for(int i =1; i <= n; i++) {
			if(i%3 == 0 && i%5 == 0) {
				continue;
			}
			if(i%3 == 0) {
				continue;
			}
			if(i%5 == 0) {
				continue;
			}
			ans += i;
		}


		//-------------------------------------------------------------------------------------

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	} main {

		long ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

		int n = sc.nextInt();
//		int k = sc.nextInt();

		//-------------------------------------------------------------------------------------

		for(int i =1; i <= n; i++) {
			if(i%3 == 0 && i%5 == 0) {
				continue;
			}
			if(i%3 == 0) {
				continue;
			}
			if(i%5 == 0) {
				continue;
			}
			ans += i;
		}


		//-------------------------------------------------------------------------------------

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	} long ans = 0; ans 0 Scanner sc = new Scanner(System.in); sc new Scanner(System.in) boolean f = false; f false int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc for(int i =1; i <= n; i++) {
			if(i%3 == 0 && i%5 == 0) {
				continue;
			}
			if(i%3 == 0) {
				continue;
			}
			if(i%5 == 0) {
				continue;
			}
			ans += i;
		} int i =1; int i =1; i 1 i <= n i n i++ i++ i {
			if(i%3 == 0 && i%5 == 0) {
				continue;
			}
			if(i%3 == 0) {
				continue;
			}
			if(i%5 == 0) {
				continue;
			}
			ans += i;
		} {
			if(i%3 == 0 && i%5 == 0) {
				continue;
			}
			if(i%3 == 0) {
				continue;
			}
			if(i%5 == 0) {
				continue;
			}
			ans += i;
		} if(i%3 == 0 && i%5 == 0) {
				continue;
			} i%3 == 0 && i%5 == 0 i%3 == 0 i%3 i 3 0 i%5 == 0 i%5 i 5 0 {
				continue;
			} continue; if(i%3 == 0) {
				continue;
			} i%3 == 0 i%3 i 3 0 {
				continue;
			} continue; if(i%5 == 0) {
				continue;
			} i%5 == 0 i%5 i 5 0 {
				continue;
			} continue; ans += i ans i System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {


	final int MOD = 1000000007;


	public static void main(String[] args) {

		long ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

		int n = sc.nextInt();
//		int k = sc.nextInt();

		//-------------------------------------------------------------------------------------

		for(int i =1; i <= n; i++) {
			if(i%3 == 0 && i%5 == 0) {
				continue;
			}
			if(i%3 == 0) {
				continue;
			}
			if(i%5 == 0) {
				continue;
			}
			ans += i;
		}


		//-------------------------------------------------------------------------------------

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	}
} public class Main {


	final int MOD = 1000000007;


	public static void main(String[] args) {

		long ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

		int n = sc.nextInt();
//		int k = sc.nextInt();

		//-------------------------------------------------------------------------------------

		for(int i =1; i <= n; i++) {
			if(i%3 == 0 && i%5 == 0) {
				continue;
			}
			if(i%3 == 0) {
				continue;
			}
			if(i%5 == 0) {
				continue;
			}
			ans += i;
		}


		//-------------------------------------------------------------------------------------

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	}
} Main
import java.util.Scanner;


public class Main {


	final int MOD = 1000000007;


	public static void main(String[] args) {

		long ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

		int n = sc.nextInt();
//		int k = sc.nextInt();

		//-------------------------------------------------------------------------------------

		for(int i =1; i <= n; i++) {
			if(i%3 == 0 && i%5 == 0) {
				continue;
			}
			if(i%3 == 0) {
				continue;
			}
			if(i%5 == 0) {
				continue;
			}
			ans += i;
		}


		//-------------------------------------------------------------------------------------

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	}
}