import java.util.Scanner;

public class Main {
    private static final int[] a = new int[15];
    private static final int[] d = new int[15];
    static{
        int sum=0;
        int count = 0;
        for (int i = 0; i < 15; i++) {
            if(i%3!=0 && i%5!=0){
                sum+=i;
                count++;
            }
            a[i]=sum;
            d[i]=count;
        }
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(f(n));
    }

    public static long f(int n){
        long b = n/15;
        int c = n%15;
        return b*(b-1)/2*15*8 + b*a[14] + a[c] + d[c]*b*15;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    private static final int[] a = new int[15];
    private static final int[] d = new int[15];
    static{
        int sum=0;
        int count = 0;
        for (int i = 0; i < 15; i++) {
            if(i%3!=0 && i%5!=0){
                sum+=i;
                count++;
            }
            a[i]=sum;
            d[i]=count;
        }
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(f(n));
    }

    public static long f(int n){
        long b = n/15;
        int c = n%15;
        return b*(b-1)/2*15*8 + b*a[14] + a[c] + d[c]*b*15;
    }
} Main private static final int[] a = new int[15]; a new int[15] 15 private static final int[] d = new int[15]; d new int[15] 15 public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(f(n));
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(f(n));
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner System.out.println(f(n)) System.out.println System.out System System.out f(n) f n String[] args args public static long f(int n){
        long b = n/15;
        int c = n%15;
        return b*(b-1)/2*15*8 + b*a[14] + a[c] + d[c]*b*15;
    } f {
        long b = n/15;
        int c = n%15;
        return b*(b-1)/2*15*8 + b*a[14] + a[c] + d[c]*b*15;
    } long b = n/15; b n/15 n 15 int c = n%15; c n%15 n 15 return b*(b-1)/2*15*8 + b*a[14] + a[c] + d[c]*b*15; b*(b-1)/2*15*8 + b*a[14] + a[c] + d[c]*b*15 a[c] b*(b-1)/2*15*8 + b*a[14] + a[c] + d[c]*b*15 b*(b-1)/2*15*8 b*(b-1)/2*15*8 b*(b-1)/2 b*(b-1) b (b-1) b 1 2 15 8 b*a[14] b a[14] a 14 a[c] a c d[c]*b*15 d[c]*b*15 d[c] d c b 15 int n n public class Main {
    private static final int[] a = new int[15];
    private static final int[] d = new int[15];
    static{
        int sum=0;
        int count = 0;
        for (int i = 0; i < 15; i++) {
            if(i%3!=0 && i%5!=0){
                sum+=i;
                count++;
            }
            a[i]=sum;
            d[i]=count;
        }
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(f(n));
    }

    public static long f(int n){
        long b = n/15;
        int c = n%15;
        return b*(b-1)/2*15*8 + b*a[14] + a[c] + d[c]*b*15;
    }
} public class Main {
    private static final int[] a = new int[15];
    private static final int[] d = new int[15];
    static{
        int sum=0;
        int count = 0;
        for (int i = 0; i < 15; i++) {
            if(i%3!=0 && i%5!=0){
                sum+=i;
                count++;
            }
            a[i]=sum;
            d[i]=count;
        }
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(f(n));
    }

    public static long f(int n){
        long b = n/15;
        int c = n%15;
        return b*(b-1)/2*15*8 + b*a[14] + a[c] + d[c]*b*15;
    }
} Main
import java.util.Scanner;

public class Main {
    private static final int[] a = new int[15];
    private static final int[] d = new int[15];
    static{
        int sum=0;
        int count = 0;
        for (int i = 0; i < 15; i++) {
            if(i%3!=0 && i%5!=0){
                sum+=i;
                count++;
            }
            a[i]=sum;
            d[i]=count;
        }
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        System.out.println(f(n));
    }

    public static long f(int n){
        long b = n/15;
        int c = n%15;
        return b*(b-1)/2*15*8 + b*a[14] + a[c] + d[c]*b*15;
    }
}