#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

int main(){    
  long long N;
  cin >> N;
  int A[N],sum=0;
  for(int i=1;i<=N;i++){
    if(i%3!=0 && i%5!=0){
    sum += i;
    //cout << sum << endl;
    }
  }

  cout << sum << endl;
 
}
