#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())
 
int main() {
  int n;
  cin >> n;

  int64_t ans=0;
  rep(i, n+1){
    if(!(i%3==0 || i%5==0)) ans+=i;
  }

  cout << ans << endl;
}