#include <iostream>
using namespace std;


int main(){
  int N;
  cin >> N;
  long long int ans = 0;
  for(int ii=1; ii<=N; ii++){
    if(ii%3==0) continue;
    if(ii%5==0) continue;
    ans += ii;
  }
  cout << ans << endl;
  return 0;
}
