#include <cstdio>
#include <numeric>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <array>
using i64 = long long;
using namespace std;

int main() {
  int n;
  cin >> n;
  i64 s = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0) continue;
    if (i % 5 == 0) continue;
    s += i;
  }
  cout << s <<  "\n";
}