#include <bits/stdc++.h>
using namespace std;
 
 
//typedef  long long ll;
using ll = long long;
using ld = long double;
using uint = unsigned int ;
using ull = unsigned long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define endl "\n"
#define ioss ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
//#define all(x) x.begin(),x.end();
//#define fi first
//#define se second
 
double startTime;
double getCurrentTime()
{
    return ((double)clock()-startTime)/CLOCKS_PER_SEC;
}
 
void solve()
{
int n;cin>>n;ll sum=0;
for(int i=1;i<=n;i++)
{
  if(i%3!=0&i%5!=0)sum=sum+i;
}
  cout<<sum<<endl;
}
 
int main()
{
    startTime=(double)clock();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt,"w",stdout);
 
    ioss
    //int t;scanf("%d",&t);
   // while(t--) 
            solve();
 
    return 0;
}