#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long
using namespace std;

int main()
{
    ll n;
    cin >> n;

    ll ans = 0;
    for(int i = 1; i <= n; i ++)
    {
    	if(i % 3 != 0 && i % 5 != 0)
    		ans = ans + i;
    }
    cout << ans << endl;
}