#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  ll n;
  cin >>n;
  ll ans=0;
  for(ll i=1;i<n+1;i++){
    if(i%3!=0&&i%5!=0){
      ans = ans+i;
    }
  }
  cout <<ans<<endl;
}