#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N, total;
  cin >> N;
  total = 0;
  
  for(int i = 0;i < N;i++){
    if(i % 3 != 0 && i % 5 != 0){
    total = total + i;
    } 
  }
  cout << total << endl;
}