#include <iostream>
#include <vector>
using namespace std; using P=pair<int,int>; using ll=long long;
const ll m = 1e9+7;

int main2() {
	string s; cin>>s;
  if (s[0] == '7' || s[1]=='7' || s[2]=='7') cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

int main() {
  int n; cin>>n;
  ll an=0;
  for(int i=1;i<=n;i++) {
    if (i%3!=0 && i%5!=0) an+=i;
  }
  cout<<an<<endl;
}