#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;

typedef long long LL;
typedef long double LD;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    LL ans = 0;
    for(int i = 1;i <= n; i++){
        if(i % 3 == 0 && i % 5 == 0);
        else if(i % 3 == 0);
        else if(i % 5 == 0);
        else ans += i;
    }
    cout << ans << endl;
}