import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Long n;
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        Long sum = n*(n+1)/2-(n-n%3+3)*(n/3)/2-(n-n%5+5)*(n/5)/2+(n-n%15+15)*(n/15)/2;
        System.out.println(sum);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Long n;
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        Long sum = n*(n+1)/2-(n-n%3+3)*(n/3)/2-(n-n%5+5)*(n/5)/2+(n-n%15+15)*(n/15)/2;
        System.out.println(sum);
    }
} Main public static void main(String[] args) {
        Long n;
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        Long sum = n*(n+1)/2-(n-n%3+3)*(n/3)/2-(n-n%5+5)*(n/5)/2+(n-n%15+15)*(n/15)/2;
        System.out.println(sum);
    } main {
        Long n;
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        Long sum = n*(n+1)/2-(n-n%3+3)*(n/3)/2-(n-n%5+5)*(n/5)/2+(n-n%15+15)*(n/15)/2;
        System.out.println(sum);
    } Long n; n Scanner sc = new Scanner(System.in); sc new Scanner(System.in) n = sc.nextLong() n sc.nextLong() sc.nextLong sc Long sum = n*(n+1)/2-(n-n%3+3)*(n/3)/2-(n-n%5+5)*(n/5)/2+(n-n%15+15)*(n/15)/2; sum n*(n+1)/2-(n-n%3+3)*(n/3)/2-(n-n%5+5)*(n/5)/2+(n-n%15+15)*(n/15)/2 n*(n+1)/2-(n-n%3+3)*(n/3)/2-(n-n%5+5)*(n/5)/2 n*(n+1)/2-(n-n%3+3)*(n/3)/2-(n-n%5+5)*(n/5)/2 n*(n+1)/2 n*(n+1) n (n+1) n 1 2 (n-n%3+3)*(n/3)/2 (n-n%3+3)*(n/3) (n-n%3+3) n-n%3 n n%3 n 3 3 (n/3) n 3 2 (n-n%5+5)*(n/5)/2 (n-n%5+5)*(n/5) (n-n%5+5) n-n%5 n n%5 n 5 5 (n/5) n 5 2 (n-n%15+15)*(n/15)/2 (n-n%15+15)*(n/15) (n-n%15+15) n-n%15 n n%15 n 15 15 (n/15) n 15 2 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) {
        Long n;
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        Long sum = n*(n+1)/2-(n-n%3+3)*(n/3)/2-(n-n%5+5)*(n/5)/2+(n-n%15+15)*(n/15)/2;
        System.out.println(sum);
    }
} public class Main {
    public static void main(String[] args) {
        Long n;
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        Long sum = n*(n+1)/2-(n-n%3+3)*(n/3)/2-(n-n%5+5)*(n/5)/2+(n-n%15+15)*(n/15)/2;
        System.out.println(sum);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Long n;
        Scanner sc = new Scanner(System.in);
        n = sc.nextLong();
        Long sum = n*(n+1)/2-(n-n%3+3)*(n/3)/2-(n-n%5+5)*(n/5)/2+(n-n%15+15)*(n/15)/2;
        System.out.println(sum);
    }
}
