import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long all = (1 + n) * n / 2;
        long n3 = n / 3;
        long all3 = (3 + 3 * n3) * n3 / 2;
        long n5 = n / 5;
        long all5 = (5 + 5 * n5) * n5 / 2;
        long n15 = n / 15;
        long all15 = (15 + 15 * n15) * n15 / 2;
        long sum = all - all3 - all5 + all15;
        System.out.println(sum);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long all = (1 + n) * n / 2;
        long n3 = n / 3;
        long all3 = (3 + 3 * n3) * n3 / 2;
        long n5 = n / 5;
        long all5 = (5 + 5 * n5) * n5 / 2;
        long n15 = n / 15;
        long all15 = (15 + 15 * n15) * n15 / 2;
        long sum = all - all3 - all5 + all15;
        System.out.println(sum);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long all = (1 + n) * n / 2;
        long n3 = n / 3;
        long all3 = (3 + 3 * n3) * n3 / 2;
        long n5 = n / 5;
        long all5 = (5 + 5 * n5) * n5 / 2;
        long n15 = n / 15;
        long all15 = (15 + 15 * n15) * n15 / 2;
        long sum = all - all3 - all5 + all15;
        System.out.println(sum);
    } main {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long all = (1 + n) * n / 2;
        long n3 = n / 3;
        long all3 = (3 + 3 * n3) * n3 / 2;
        long n5 = n / 5;
        long all5 = (5 + 5 * n5) * n5 / 2;
        long n15 = n / 15;
        long all15 = (15 + 15 * n15) * n15 / 2;
        long sum = all - all3 - all5 + all15;
        System.out.println(sum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long n = sc.nextLong(); n sc.nextLong() sc.nextLong sc long all = (1 + n) * n / 2; all (1 + n) * n / 2 (1 + n) * n (1 + n) 1 n n 2 long n3 = n / 3; n3 n / 3 n 3 long all3 = (3 + 3 * n3) * n3 / 2; all3 (3 + 3 * n3) * n3 / 2 (3 + 3 * n3) * n3 (3 + 3 * n3) 3 3 * n3 3 n3 n3 2 long n5 = n / 5; n5 n / 5 n 5 long all5 = (5 + 5 * n5) * n5 / 2; all5 (5 + 5 * n5) * n5 / 2 (5 + 5 * n5) * n5 (5 + 5 * n5) 5 5 * n5 5 n5 n5 2 long n15 = n / 15; n15 n / 15 n 15 long all15 = (15 + 15 * n15) * n15 / 2; all15 (15 + 15 * n15) * n15 / 2 (15 + 15 * n15) * n15 (15 + 15 * n15) 15 15 * n15 15 n15 n15 2 long sum = all - all3 - all5 + all15; sum all - all3 - all5 + all15 all - all3 - all5 all - all3 - all5 all all3 all5 all15 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long all = (1 + n) * n / 2;
        long n3 = n / 3;
        long all3 = (3 + 3 * n3) * n3 / 2;
        long n5 = n / 5;
        long all5 = (5 + 5 * n5) * n5 / 2;
        long n15 = n / 15;
        long all15 = (15 + 15 * n15) * n15 / 2;
        long sum = all - all3 - all5 + all15;
        System.out.println(sum);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long all = (1 + n) * n / 2;
        long n3 = n / 3;
        long all3 = (3 + 3 * n3) * n3 / 2;
        long n5 = n / 5;
        long all5 = (5 + 5 * n5) * n5 / 2;
        long n15 = n / 15;
        long all15 = (15 + 15 * n15) * n15 / 2;
        long sum = all - all3 - all5 + all15;
        System.out.println(sum);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long all = (1 + n) * n / 2;
        long n3 = n / 3;
        long all3 = (3 + 3 * n3) * n3 / 2;
        long n5 = n / 5;
        long all5 = (5 + 5 * n5) * n5 / 2;
        long n15 = n / 15;
        long all15 = (15 + 15 * n15) * n15 / 2;
        long sum = all - all3 - all5 + all15;
        System.out.println(sum);
    }
}