#include<bits/stdc++.h>
#define iamabatman ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precision cout.precision(10); cout << fixed;
#define endl '\n'
#define ll long long int
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
using namespace std;
int main()
{

  iamabatman
  precision
  ll sum=0;
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    if(i%3!=0 && i%5!=0)
      sum+=i;
  }
  cout<<sum;
  return 0;
}

