#include <bits/stdc++.h>
using namespace std;

int main () {
  long long N;
  cin >> N;
  long long ans = 0;
  for (int i = 1;i <= N; i++){
    bool plus = true;
    if (i%3 == 0) plus = false;
    if (i%5 == 0) plus = false;
    if (plus) ans += i;
  }
  cout << ans << endl;
}
