#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
 
using namespace std;
int main()
{
  long N;
  long ans;

  ans = 0;
  cin >> N;

  for(int i = 0; i < N; i++)
  if((i%3 != 0) || (i%5 != 0)){
    ans += i;
  }

  cout << ans << endl;
 
  
      return 0;
}