#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
#define II pair<int,int>
#define mk make_pair

const int N=1e5+10;
const ll maxN=1e18+10;
const ll MOD=10000000007;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ll ans=0; int n;
  cin >> n;
  FOR(i,1,n)
   if (i%3!=0&&i%5!=0) ans+=i;
  cout << ans;
}
    