import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Question question = new Question();
        question.solve(sc);
    }

    static class Question {
        public void solve(Scanner sc) {
            int n = sc.nextInt();
            long sum = 0;
            while(n > 0) {
                if(n % 3 == 0 && n % 5 == 0 || n % 3 == 0 || n % 5 == 0) {
                    n--;
                    continue;
                }
                sum += n--;
            }
            System.out.println(sum);
        }
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Question question = new Question();
        question.solve(sc);
    }

    static class Question {
        public void solve(Scanner sc) {
            int n = sc.nextInt();
            long sum = 0;
            while(n > 0) {
                if(n % 3 == 0 && n % 5 == 0 || n % 3 == 0 || n % 5 == 0) {
                    n--;
                    continue;
                }
                sum += n--;
            }
            System.out.println(sum);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Question question = new Question();
        question.solve(sc);
    } main {
        Scanner sc = new Scanner(System.in);
        Question question = new Question();
        question.solve(sc);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Question question = new Question(); question new Question() question.solve(sc) question.solve question sc String[] args args static class Question {
        public void solve(Scanner sc) {
            int n = sc.nextInt();
            long sum = 0;
            while(n > 0) {
                if(n % 3 == 0 && n % 5 == 0 || n % 3 == 0 || n % 5 == 0) {
                    n--;
                    continue;
                }
                sum += n--;
            }
            System.out.println(sum);
        }
    } Question public void solve(Scanner sc) {
            int n = sc.nextInt();
            long sum = 0;
            while(n > 0) {
                if(n % 3 == 0 && n % 5 == 0 || n % 3 == 0 || n % 5 == 0) {
                    n--;
                    continue;
                }
                sum += n--;
            }
            System.out.println(sum);
        } solve {
            int n = sc.nextInt();
            long sum = 0;
            while(n > 0) {
                if(n % 3 == 0 && n % 5 == 0 || n % 3 == 0 || n % 5 == 0) {
                    n--;
                    continue;
                }
                sum += n--;
            }
            System.out.println(sum);
        } int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc long sum = 0; sum 0 while(n > 0) {
                if(n % 3 == 0 && n % 5 == 0 || n % 3 == 0 || n % 5 == 0) {
                    n--;
                    continue;
                }
                sum += n--;
            } n > 0 n 0 {
                if(n % 3 == 0 && n % 5 == 0 || n % 3 == 0 || n % 5 == 0) {
                    n--;
                    continue;
                }
                sum += n--;
            } if(n % 3 == 0 && n % 5 == 0 || n % 3 == 0 || n % 5 == 0) {
                    n--;
                    continue;
                } n % 3 == 0 && n % 5 == 0 || n % 3 == 0 || n % 5 == 0 n % 3 == 0 && n % 5 == 0 || n % 3 == 0 || n % 5 == 0 n % 3 == 0 && n % 5 == 0 n % 3 == 0 n % 3 n 3 0 n % 5 == 0 n % 5 n 5 0 n % 3 == 0 n % 3 n 3 0 n % 5 == 0 n % 5 n 5 0 {
                    n--;
                    continue;
                } n-- n continue; sum += n-- sum n-- n System.out.println(sum) System.out.println System.out System System.out sum Scanner sc sc public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Question question = new Question();
        question.solve(sc);
    }

    static class Question {
        public void solve(Scanner sc) {
            int n = sc.nextInt();
            long sum = 0;
            while(n > 0) {
                if(n % 3 == 0 && n % 5 == 0 || n % 3 == 0 || n % 5 == 0) {
                    n--;
                    continue;
                }
                sum += n--;
            }
            System.out.println(sum);
        }
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Question question = new Question();
        question.solve(sc);
    }

    static class Question {
        public void solve(Scanner sc) {
            int n = sc.nextInt();
            long sum = 0;
            while(n > 0) {
                if(n % 3 == 0 && n % 5 == 0 || n % 3 == 0 || n % 5 == 0) {
                    n--;
                    continue;
                }
                sum += n--;
            }
            System.out.println(sum);
        }
    }
} Main
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Question question = new Question();
        question.solve(sc);
    }

    static class Question {
        public void solve(Scanner sc) {
            int n = sc.nextInt();
            long sum = 0;
            while(n > 0) {
                if(n % 3 == 0 && n % 5 == 0 || n % 3 == 0 || n % 5 == 0) {
                    n--;
                    continue;
                }
                sum += n--;
            }
            System.out.println(sum);
        }
    }
}
