#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); i++)

int main() {
    /*変数定義，入力*/
    ll N;
    cin >> N;
    
    //ll A, B;cin >> A >> B;
    //vector<ll> a(N);  rep(i, N) cin >> a[i];
    
    /*演算*/
    ll sum = 0; 
    for(int i = 1; i <= N; i++){
       if(i%3 == 0 || i%5 == 0){
       }else{
           sum += i;
       }
    }
    /*出力*/
    cout << sum << endl;
    /*終了*/
    return 0;
}