import java.util.Scanner;

public class Main {//Risolto in =(1)
    public static long sum(long n) {
        return n * (n + 1) / 2;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();

        long res = sum(n) - sum(n/3) * 3 - sum(n / 5) * 5 + sum(n / 15) * 15;

        System.out.print(res);
    }
} import java.util.Scanner; Scanner java.util public class Main {//Risolto in =(1)
    public static long sum(long n) {
        return n * (n + 1) / 2;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();

        long res = sum(n) - sum(n/3) * 3 - sum(n / 5) * 5 + sum(n / 15) * 15;

        System.out.print(res);
    }
} Main public static long sum(long n) {
        return n * (n + 1) / 2;
    } sum {
        return n * (n + 1) / 2;
    } return n * (n + 1) / 2; n * (n + 1) / 2 n * (n + 1) n (n + 1) n 1 2 long n n public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();

        long res = sum(n) - sum(n/3) * 3 - sum(n / 5) * 5 + sum(n / 15) * 15;

        System.out.print(res);
    } main {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();

        long res = sum(n) - sum(n/3) * 3 - sum(n / 5) * 5 + sum(n / 15) * 15;

        System.out.print(res);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long res = sum(n) - sum(n/3) * 3 - sum(n / 5) * 5 + sum(n / 15) * 15; res sum(n) - sum(n/3) * 3 - sum(n / 5) * 5 + sum(n / 15) * 15 sum(n) - sum(n/3) * 3 - sum(n / 5) * 5 sum(n) - sum(n/3) * 3 - sum(n / 5) * 5 sum(n) sum n sum(n/3) * 3 sum(n/3) sum n/3 n 3 3 sum(n / 5) * 5 sum(n / 5) sum n / 5 n 5 5 sum(n / 15) * 15 sum(n / 15) sum n / 15 n 15 15 System.out.print(res) System.out.print System.out System System.out res String[] args args public class Main {//Risolto in =(1)
    public static long sum(long n) {
        return n * (n + 1) / 2;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();

        long res = sum(n) - sum(n/3) * 3 - sum(n / 5) * 5 + sum(n / 15) * 15;

        System.out.print(res);
    }
} public class Main {//Risolto in =(1)
    public static long sum(long n) {
        return n * (n + 1) / 2;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();

        long res = sum(n) - sum(n/3) * 3 - sum(n / 5) * 5 + sum(n / 15) * 15;

        System.out.print(res);
    }
} Main
import java.util.Scanner;

public class Main {//Risolto in =(1)
    public static long sum(long n) {
        return n * (n + 1) / 2;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();

        long res = sum(n) - sum(n/3) * 3 - sum(n / 5) * 5 + sum(n / 15) * 15;

        System.out.print(res);
    }
}
