import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());

        long sum = n*(n+1)/2;

        long n3 = n/3;
        long sum3 = 3*(n3*(n3+1)/2);
        long n5 = n/5;

        long sum5 = 5*(n5*(n5+1)/2);

        long n15 = n/15;
        long sum15 = 15*(n15*(n15+1)/2);

        System.out.println(sum-sum3-sum5+sum15);
        System.out.flush();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());

        long sum = n*(n+1)/2;

        long n3 = n/3;
        long sum3 = 3*(n3*(n3+1)/2);
        long n5 = n/5;

        long sum5 = 5*(n5*(n5+1)/2);

        long n15 = n/15;
        long sum15 = 15*(n15*(n15+1)/2);

        System.out.println(sum-sum3-sum5+sum15);
        System.out.flush();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());

        long sum = n*(n+1)/2;

        long n3 = n/3;
        long sum3 = 3*(n3*(n3+1)/2);
        long n5 = n/5;

        long sum5 = 5*(n5*(n5+1)/2);

        long n15 = n/15;
        long sum15 = 15*(n15*(n15+1)/2);

        System.out.println(sum-sum3-sum5+sum15);
        System.out.flush();
    } main {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());

        long sum = n*(n+1)/2;

        long n3 = n/3;
        long sum3 = 3*(n3*(n3+1)/2);
        long n5 = n/5;

        long sum5 = 5*(n5*(n5+1)/2);

        long n15 = n/15;
        long sum15 = 15*(n15*(n15+1)/2);

        System.out.println(sum-sum3-sum5+sum15);
        System.out.flush();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long n = Long.parseLong(sc.next()); n Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc long sum = n*(n+1)/2; sum n*(n+1)/2 n*(n+1) n (n+1) n 1 2 long n3 = n/3; n3 n/3 n 3 long sum3 = 3*(n3*(n3+1)/2); sum3 3*(n3*(n3+1)/2) 3 (n3*(n3+1)/2) n3*(n3+1) n3 (n3+1) n3 1 2 long n5 = n/5; n5 n/5 n 5 long sum5 = 5*(n5*(n5+1)/2); sum5 5*(n5*(n5+1)/2) 5 (n5*(n5+1)/2) n5*(n5+1) n5 (n5+1) n5 1 2 long n15 = n/15; n15 n/15 n 15 long sum15 = 15*(n15*(n15+1)/2); sum15 15*(n15*(n15+1)/2) 15 (n15*(n15+1)/2) n15*(n15+1) n15 (n15+1) n15 1 2 System.out.println(sum-sum3-sum5+sum15) System.out.println System.out System System.out sum-sum3-sum5+sum15 sum-sum3-sum5 sum-sum3-sum5 sum sum3 sum5 sum15 System.out.flush() System.out.flush System.out System System.out String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());

        long sum = n*(n+1)/2;

        long n3 = n/3;
        long sum3 = 3*(n3*(n3+1)/2);
        long n5 = n/5;

        long sum5 = 5*(n5*(n5+1)/2);

        long n15 = n/15;
        long sum15 = 15*(n15*(n15+1)/2);

        System.out.println(sum-sum3-sum5+sum15);
        System.out.flush();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());

        long sum = n*(n+1)/2;

        long n3 = n/3;
        long sum3 = 3*(n3*(n3+1)/2);
        long n5 = n/5;

        long sum5 = 5*(n5*(n5+1)/2);

        long n15 = n/15;
        long sum15 = 15*(n15*(n15+1)/2);

        System.out.println(sum-sum3-sum5+sum15);
        System.out.flush();
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());

        long sum = n*(n+1)/2;

        long n3 = n/3;
        long sum3 = 3*(n3*(n3+1)/2);
        long n5 = n/5;

        long sum5 = 5*(n5*(n5+1)/2);

        long n15 = n/15;
        long sum15 = 15*(n15*(n15+1)/2);

        System.out.println(sum-sum3-sum5+sum15);
        System.out.flush();
    }
}