#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

int main()
{
  ll n;
  cin >> n;
  vector<ll> num(n);
  for(ll i = 1;i <= n;i++)
  {
    num[i-1] = i;
  }
  ll sum = 0;
  for(int i = 0;i < n;i++)
  {
    if(num[i]%3 != 0 &&num[i]%5 != 0)
    {
      sum += num[i];
    }
  }
  cout << sum << endl;
}
