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

int main() {
  long n,sum,fs,bs,fbs;
  cin >> n;
  sum = n,fs = 0, bs = 0, fbs = 0;
  for (int i = 0; i < n; i++) {
    sum += i;
  }
  for (int i = 3; i <= n; i += 3) {
    fs += i;
  }
  for (int i = 5; i <= n; i += 5) {
    bs += i;
  }
  for (int i = 15; i <= n; i += 15) {
    fbs += i;
  }
  cout << sum-fs-bs+fbs << endl;
}
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  ll N; cin >> N;

  ll ans = 0;
  for(ll i = 1; i <= N; i++){
    if( i%3 == 0 || i%5 == 0){

    } else {
      ans += i;
    }
  }
  cout << ans << endl;
}
