#include <bits/stdc++.h>
#define ll long long
#define lb long double
#define f(i,a,b) for(ll i = a;i <= b;i ++)
#define fi(i,a,b) for(ll i = a;i >= b;i --)
using namespace std;
ll n,dem;
int main()
{
    cin >> n;
    f(i,1,n)
    {
        if(i % 3 != 0 && i % 5 != 0) dem += i;
    }
    cout << dem;
    return 0;
}
