#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define pii pair<long long,long long>
#define endl '\n'

using namespace std;

signed main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans=0;
    for(int i=1;i<=n;i++){
        if(i%3==0 || i%5==0){
            ans=ans;
        }
        else{
            ans+=i;
        }
    }
    cout << ans;
}