#include <bits/stdc++.h>
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0&&i%5!=0)
        ans+=i;
    }
    cout<<ans;
    return 0;
}
//make all values ll