import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextInt();
        long f=n/3;
        long sum=0;
        sum+=((f)*(6+(f-1)*3))/2;
        long b=n/5;
        sum+=((b)*(10+(b-1)*5))/2;
        long total=(n*(n+1))/2;
        long fb=n/15;
        sum-=((fb)*(30+(fb-1)*15))/2;
        System.out.println(total-sum);
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextInt();
        long f=n/3;
        long sum=0;
        sum+=((f)*(6+(f-1)*3))/2;
        long b=n/5;
        sum+=((b)*(10+(b-1)*5))/2;
        long total=(n*(n+1))/2;
        long fb=n/15;
        sum-=((fb)*(30+(fb-1)*15))/2;
        System.out.println(total-sum);
    }
} Main public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextInt();
        long f=n/3;
        long sum=0;
        sum+=((f)*(6+(f-1)*3))/2;
        long b=n/5;
        sum+=((b)*(10+(b-1)*5))/2;
        long total=(n*(n+1))/2;
        long fb=n/15;
        sum-=((fb)*(30+(fb-1)*15))/2;
        System.out.println(total-sum);
    } main {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextInt();
        long f=n/3;
        long sum=0;
        sum+=((f)*(6+(f-1)*3))/2;
        long b=n/5;
        sum+=((b)*(10+(b-1)*5))/2;
        long total=(n*(n+1))/2;
        long fb=n/15;
        sum-=((fb)*(30+(fb-1)*15))/2;
        System.out.println(total-sum);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) long n=sc.nextInt(); n sc.nextInt() sc.nextInt sc long f=n/3; f n/3 n 3 long sum=0; sum 0 sum+=((f)*(6+(f-1)*3))/2 sum ((f)*(6+(f-1)*3))/2 ((f)*(6+(f-1)*3)) (f) (6+(f-1)*3) 6 (f-1)*3 (f-1) f 1 3 2 long b=n/5; b n/5 n 5 sum+=((b)*(10+(b-1)*5))/2 sum ((b)*(10+(b-1)*5))/2 ((b)*(10+(b-1)*5)) (b) (10+(b-1)*5) 10 (b-1)*5 (b-1) b 1 5 2 long total=(n*(n+1))/2; total (n*(n+1))/2 (n*(n+1)) n (n+1) n 1 2 long fb=n/15; fb n/15 n 15 sum-=((fb)*(30+(fb-1)*15))/2 sum ((fb)*(30+(fb-1)*15))/2 ((fb)*(30+(fb-1)*15)) (fb) (30+(fb-1)*15) 30 (fb-1)*15 (fb-1) fb 1 15 2 System.out.println(total-sum) System.out.println System.out System System.out total-sum total sum String[] args args public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextInt();
        long f=n/3;
        long sum=0;
        sum+=((f)*(6+(f-1)*3))/2;
        long b=n/5;
        sum+=((b)*(10+(b-1)*5))/2;
        long total=(n*(n+1))/2;
        long fb=n/15;
        sum-=((fb)*(30+(fb-1)*15))/2;
        System.out.println(total-sum);
    }
} public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextInt();
        long f=n/3;
        long sum=0;
        sum+=((f)*(6+(f-1)*3))/2;
        long b=n/5;
        sum+=((b)*(10+(b-1)*5))/2;
        long total=(n*(n+1))/2;
        long fb=n/15;
        sum-=((fb)*(30+(fb-1)*15))/2;
        System.out.println(total-sum);
    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextInt();
        long f=n/3;
        long sum=0;
        sum+=((f)*(6+(f-1)*3))/2;
        long b=n/5;
        sum+=((b)*(10+(b-1)*5))/2;
        long total=(n*(n+1))/2;
        long fb=n/15;
        sum-=((fb)*(30+(fb-1)*15))/2;
        System.out.println(total-sum);
    }
}
