import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int N = Integer.parseInt(sc.next());
      long result = 0;
      for (int i = 0; i <= N; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
          result += i;
        }
      }

      System.out.println(result);
    }
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int N = Integer.parseInt(sc.next());
      long result = 0;
      for (int i = 0; i <= N; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
          result += i;
        }
      }

      System.out.println(result);
    }
  }
} Main public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int N = Integer.parseInt(sc.next());
      long result = 0;
      for (int i = 0; i <= N; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
          result += i;
        }
      }

      System.out.println(result);
    }
  } main {
    try (Scanner sc = new Scanner(System.in)) {
      int N = Integer.parseInt(sc.next());
      long result = 0;
      for (int i = 0; i <= N; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
          result += i;
        }
      }

      System.out.println(result);
    }
  } try (Scanner sc = new Scanner(System.in)) {
      int N = Integer.parseInt(sc.next());
      long result = 0;
      for (int i = 0; i <= N; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
          result += i;
        }
      }

      System.out.println(result);
    } {
      int N = Integer.parseInt(sc.next());
      long result = 0;
      for (int i = 0; i <= N; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
          result += i;
        }
      }

      System.out.println(result);
    } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc long result = 0; result 0 for (int i = 0; i <= N; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
          result += i;
        }
      } int i = 0; int i = 0; i 0 i <= N i N i++ i++ i {
        if (!(i % 3 == 0 || i % 5 == 0)) {
          result += i;
        }
      } {
        if (!(i % 3 == 0 || i % 5 == 0)) {
          result += i;
        }
      } if (!(i % 3 == 0 || i % 5 == 0)) {
          result += i;
        } !(i % 3 == 0 || i % 5 == 0) (i % 3 == 0 || i % 5 == 0) i % 3 == 0 i % 3 i 3 0 i % 5 == 0 i % 5 i 5 0 {
          result += i;
        } result += i result i System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int N = Integer.parseInt(sc.next());
      long result = 0;
      for (int i = 0; i <= N; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
          result += i;
        }
      }

      System.out.println(result);
    }
  }
} public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int N = Integer.parseInt(sc.next());
      long result = 0;
      for (int i = 0; i <= N; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
          result += i;
        }
      }

      System.out.println(result);
    }
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int N = Integer.parseInt(sc.next());
      long result = 0;
      for (int i = 0; i <= N; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
          result += i;
        }
      }

      System.out.println(result);
    }
  }
}
