import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str = lines[0];
        int n = Integer.parseInt(str);
        int[] x = new int[n];
        long total = 0;
            for (int i = 0; i < n; i++){
                x[i] = i + 1;
            }
            for (int i = 0; i < n; i++){
                if(x[i] % 3 != 0 && x[i] % 5 != 0){
                    total = total + x[i];
                }
            }
        System.out.println(total);
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str = lines[0];
        int n = Integer.parseInt(str);
        int[] x = new int[n];
        long total = 0;
            for (int i = 0; i < n; i++){
                x[i] = i + 1;
            }
            for (int i = 0; i < n; i++){
                if(x[i] % 3 != 0 && x[i] % 5 != 0){
                    total = total + x[i];
                }
            }
        System.out.println(total);
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
} Main public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str = lines[0];
        int n = Integer.parseInt(str);
        int[] x = new int[n];
        long total = 0;
            for (int i = 0; i < n; i++){
                x[i] = i + 1;
            }
            for (int i = 0; i < n; i++){
                if(x[i] % 3 != 0 && x[i] % 5 != 0){
                    total = total + x[i];
                }
            }
        System.out.println(total);
   } main {
        String[] lines = getStdin();
        String str = lines[0];
        int n = Integer.parseInt(str);
        int[] x = new int[n];
        long total = 0;
            for (int i = 0; i < n; i++){
                x[i] = i + 1;
            }
            for (int i = 0; i < n; i++){
                if(x[i] % 3 != 0 && x[i] % 5 != 0){
                    total = total + x[i];
                }
            }
        System.out.println(total);
   } String[] lines = getStdin(); lines getStdin() getStdin String str = lines[0]; str lines[0] lines 0 int n = Integer.parseInt(str); n Integer.parseInt(str) Integer.parseInt Integer str int[] x = new int[n]; x new int[n] n long total = 0; total 0 for (int i = 0; i < n; i++){
                x[i] = i + 1;
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                x[i] = i + 1;
            } {
                x[i] = i + 1;
            } x[i] = i + 1 x[i] x i i + 1 i 1 for (int i = 0; i < n; i++){
                if(x[i] % 3 != 0 && x[i] % 5 != 0){
                    total = total + x[i];
                }
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                if(x[i] % 3 != 0 && x[i] % 5 != 0){
                    total = total + x[i];
                }
            } {
                if(x[i] % 3 != 0 && x[i] % 5 != 0){
                    total = total + x[i];
                }
            } if(x[i] % 3 != 0 && x[i] % 5 != 0){
                    total = total + x[i];
                } x[i] % 3 != 0 && x[i] % 5 != 0 x[i] % 3 != 0 x[i] % 3 x[i] x i 3 0 x[i] % 5 != 0 x[i] % 5 x[i] x i 5 0 {
                    total = total + x[i];
                } total = total + x[i] total total + x[i] total x[i] x i System.out.println(total) System.out.println System.out System System.out total String[] args args private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  } getStdin {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) ArrayList<String> lines = new ArrayList<>(); lines new ArrayList<>() while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    } scanner.hasNext() scanner.hasNext scanner {
      lines.add(scanner.nextLine());
    } lines.add(scanner.nextLine()) lines.add lines scanner.nextLine() scanner.nextLine scanner return lines.toArray(new String[lines.size()]); lines.toArray(new String[lines.size()]) lines.toArray lines new String[lines.size()] lines.size() lines.size lines public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str = lines[0];
        int n = Integer.parseInt(str);
        int[] x = new int[n];
        long total = 0;
            for (int i = 0; i < n; i++){
                x[i] = i + 1;
            }
            for (int i = 0; i < n; i++){
                if(x[i] % 3 != 0 && x[i] % 5 != 0){
                    total = total + x[i];
                }
            }
        System.out.println(total);
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
} public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str = lines[0];
        int n = Integer.parseInt(str);
        int[] x = new int[n];
        long total = 0;
            for (int i = 0; i < n; i++){
                x[i] = i + 1;
            }
            for (int i = 0; i < n; i++){
                if(x[i] % 3 != 0 && x[i] % 5 != 0){
                    total = total + x[i];
                }
            }
        System.out.println(total);
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str = lines[0];
        int n = Integer.parseInt(str);
        int[] x = new int[n];
        long total = 0;
            for (int i = 0; i < n; i++){
                x[i] = i + 1;
            }
            for (int i = 0; i < n; i++){
                if(x[i] % 3 != 0 && x[i] % 5 != 0){
                    total = total + x[i];
                }
            }
        System.out.println(total);
   }
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
}