#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    ll N=0;
    cin >> N;
    ll count=0;;
    for(ll i=1;i<=N;i++){
        if(i%3!=0&&i%5!=0){
            count+=i;
        }
    }
    
    cout << count;

}