// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int N;
  cin >> N;

  long long sum = 0;
  rep(i,N+1) {
    if (i % 3 == 0 || i % 5 == 0) continue;
    sum += i;
  }

  cout << sum << endl;

  return 0;
}
