#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  int scan; // scanf result
  ull answer; // to output 
  int n; // to input 

  scan = scanf("%d", &n);
  answer = 0;
  for (int k = 1; k <= n; k++) {
    if (k % 5 != 0 && k % 3 != 0) {
      answer += k;
    }
  }

  printf("%llu", answer);
  return (0);
}
