import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 0;

    for (int n = 1; n <= N; n++) {
      int a = n % 3;
      int b = n % 5;
      if (a != 0 && b != 0) {
        ans = ans + n;
      }
    }
    
    System.out.println(ans);
  }
} import java.util.*; util.* java class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 0;

    for (int n = 1; n <= N; n++) {
      int a = n % 3;
      int b = n % 5;
      if (a != 0 && b != 0) {
        ans = ans + n;
      }
    }
    
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 0;

    for (int n = 1; n <= N; n++) {
      int a = n % 3;
      int b = n % 5;
      if (a != 0 && b != 0) {
        ans = ans + n;
      }
    }
    
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 0;

    for (int n = 1; n <= N; n++) {
      int a = n % 3;
      int b = n % 5;
      if (a != 0 && b != 0) {
        ans = ans + n;
      }
    }
    
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc long ans = 0; ans 0 for (int n = 1; n <= N; n++) {
      int a = n % 3;
      int b = n % 5;
      if (a != 0 && b != 0) {
        ans = ans + n;
      }
    } int n = 1; int n = 1; n 1 n <= N n N n++ n++ n {
      int a = n % 3;
      int b = n % 5;
      if (a != 0 && b != 0) {
        ans = ans + n;
      }
    } {
      int a = n % 3;
      int b = n % 5;
      if (a != 0 && b != 0) {
        ans = ans + n;
      }
    } int a = n % 3; a n % 3 n 3 int b = n % 5; b n % 5 n 5 if (a != 0 && b != 0) {
        ans = ans + n;
      } a != 0 && b != 0 a != 0 a 0 b != 0 b 0 {
        ans = ans + n;
      } ans = ans + n ans ans + n ans n System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 0;

    for (int n = 1; n <= N; n++) {
      int a = n % 3;
      int b = n % 5;
      if (a != 0 && b != 0) {
        ans = ans + n;
      }
    }
    
    System.out.println(ans);
  }
}