#include <bits/stdc++.h>
#include <vector>
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;

  vector<ll> a(n+1);
  for(int i = 1;i <= n; i++) {
    if(i%15 == 0){
      a[i] = 0;
    } else if(i%3 == 0) {
      a[i] = 0;
    } else if(i%5 == 0) {
      a[i] = 0;
    } else {
      a[i] = i;
    }
  }

  long long ans = 0;
  for (int i  = 1; i <= n; i++) {
    ans += a[i];
  }

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