import java.util.*;

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

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