#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  ll N;
  cin >> N;
  vector<int> A(N+1);
  ll ans = 0;
  for(int i = 1;i<=N;i++){
    if(i%15 == 0){}
    else if(i%3 == 0){}
    else if(i%5 == 0){}
    else A[i] = i;
  }
  rep(i, N+1){
    ans += A[i];
  }
  cout << ans << endl;
}
