import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(),x = 0;
        long b = a / 15;
        long c = a / 5;
        long d = a / 3;
        for (int i = 1; i <= a; i++) {
            if(i % 3 == 0)continue;
            if(i % 5 == 0)continue;
            x += i;
        }
        System.out.println(x);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(),x = 0;
        long b = a / 15;
        long c = a / 5;
        long d = a / 3;
        for (int i = 1; i <= a; i++) {
            if(i % 3 == 0)continue;
            if(i % 5 == 0)continue;
            x += i;
        }
        System.out.println(x);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(),x = 0;
        long b = a / 15;
        long c = a / 5;
        long d = a / 3;
        for (int i = 1; i <= a; i++) {
            if(i % 3 == 0)continue;
            if(i % 5 == 0)continue;
            x += i;
        }
        System.out.println(x);
    } main {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(),x = 0;
        long b = a / 15;
        long c = a / 5;
        long d = a / 3;
        for (int i = 1; i <= a; i++) {
            if(i % 3 == 0)continue;
            if(i % 5 == 0)continue;
            x += i;
        }
        System.out.println(x);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long a = sc.nextLong() a sc.nextLong() sc.nextLong sc x = 0; x 0 long b = a / 15; b a / 15 a 15 long c = a / 5; c a / 5 a 5 long d = a / 3; d a / 3 a 3 for (int i = 1; i <= a; i++) {
            if(i % 3 == 0)continue;
            if(i % 5 == 0)continue;
            x += i;
        } int i = 1; int i = 1; i 1 i <= a i a i++ i++ i {
            if(i % 3 == 0)continue;
            if(i % 5 == 0)continue;
            x += i;
        } {
            if(i % 3 == 0)continue;
            if(i % 5 == 0)continue;
            x += i;
        } if(i % 3 == 0)continue; i % 3 == 0 i % 3 i 3 0 continue; if(i % 5 == 0)continue; i % 5 == 0 i % 5 i 5 0 continue; x += i x i System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(),x = 0;
        long b = a / 15;
        long c = a / 5;
        long d = a / 3;
        for (int i = 1; i <= a; i++) {
            if(i % 3 == 0)continue;
            if(i % 5 == 0)continue;
            x += i;
        }
        System.out.println(x);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(),x = 0;
        long b = a / 15;
        long c = a / 5;
        long d = a / 3;
        for (int i = 1; i <= a; i++) {
            if(i % 3 == 0)continue;
            if(i % 5 == 0)continue;
            x += i;
        }
        System.out.println(x);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong(),x = 0;
        long b = a / 15;
        long c = a / 5;
        long d = a / 3;
        for (int i = 1; i <= a; i++) {
            if(i % 3 == 0)continue;
            if(i % 5 == 0)continue;
            x += i;
        }
        System.out.println(x);
    }
}
