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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}

ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){

  if(s.length() == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}





// substr(start, len)

int main(){
  int N;

  cin >> N;
  ll sum = 0;

  rep(i, 0, N){
    if(i % 3 != 0 && i % 5 != 0){
      sum += i;
    }
  }

  cout << sum << endl;




  // string N;
  // cin >> N;

  // rep(i, 0, 3){
  //   if(N[i] == '7'){
  //     cout << "Yes" << endl;
  //     return 0;
  //   }
  // }

  // cout << "No" << endl;

  // cout << setprecision(8) << ans << endl;  // For double
// CHECK if it's possible to overflow!!
}