#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 100000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)

int main(){
    ll N,sum=0;
    cin >> N;
    for(ll i=1;i<=N;i++){
        if(i%3 !=0 && i%5 !=0) sum +=i;
    } 
    cout << sum << endl;
}