/*
susheel_7
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long int


int main() {
    ll n,s,ans=0,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0)
            continue;
        else
            ans+=i;
    }
    cout<<ans;
    return 0;
}