#include<bits/stdc++.h>
#define rep(i, n) for(i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007

int main(){
  ll N, i, ans = 0;
  cin >> N;
  
  rep(i, N + 1){
    if(i % 3 == 0 || i%5 == 0){
      continue;
    }
    ans += i;
  }

  cout << ans << endl;
  return 0;
}