#include <iostream>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()

int main() {
  ll n, ans = 0;
  cin >> n;
  for (ll i = 1; i <= n; i++) {
    if (i % 5 != 0 && i % 3 != 0) {
      ans += i;
    }
  }
  cout << ans << endl;
}