import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = Integer.parseInt(sc.next());
		long total = 0;
		
		for(int i = 1; i <= N ;i++){
			if(i % 3 != 0 && i % 5 != 0){
				total += i;
			}
		}
		System.out.println(total);
	}
} import java.util.*; util.* java class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = Integer.parseInt(sc.next());
		long total = 0;
		
		for(int i = 1; i <= N ;i++){
			if(i % 3 != 0 && i % 5 != 0){
				total += i;
			}
		}
		System.out.println(total);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = Integer.parseInt(sc.next());
		long total = 0;
		
		for(int i = 1; i <= N ;i++){
			if(i % 3 != 0 && i % 5 != 0){
				total += i;
			}
		}
		System.out.println(total);
	} main {
		Scanner sc = new Scanner(System.in);
		
		int N = Integer.parseInt(sc.next());
		long total = 0;
		
		for(int i = 1; i <= N ;i++){
			if(i % 3 != 0 && i % 5 != 0){
				total += i;
			}
		}
		System.out.println(total);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc long total = 0; total 0 for(int i = 1; i <= N ;i++){
			if(i % 3 != 0 && i % 5 != 0){
				total += i;
			}
		} int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
			if(i % 3 != 0 && i % 5 != 0){
				total += i;
			}
		} {
			if(i % 3 != 0 && i % 5 != 0){
				total += i;
			}
		} if(i % 3 != 0 && i % 5 != 0){
				total += i;
			} i % 3 != 0 && i % 5 != 0 i % 3 != 0 i % 3 i 3 0 i % 5 != 0 i % 5 i 5 0 {
				total += i;
			} total += i total i System.out.println(total) System.out.println System.out System System.out total String[] args args
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = Integer.parseInt(sc.next());
		long total = 0;
		
		for(int i = 1; i <= N ;i++){
			if(i % 3 != 0 && i % 5 != 0){
				total += i;
			}
		}
		System.out.println(total);
	}
}