#include<bits/stdc++.h>
using namespace std;

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