#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
using namespace std;
 
int main(void) {
    int n, sum = 0;
    cin >> n;
    
    rep(i, n){
        if(i % 3 != 0 && i % 5 != 0){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}