#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {

ll sum=0;
ll n;
cin >> n;

for (size_t i = 1; i <= n; i++)
{
if (i%3!=0&&i%5!=0)
{
  sum+=i;
}

}

cout << sum <<endl;

}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/