#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include <bits/stdc++.h>

using namespace std;

typedef pair<long long,bool> Pair;
const long long INF = 1LL<<60;

int main(){

long long N,sum = 0;

cin >> N;

for(long long i = 1;i <= N;++i){

    if(i%3 == 0 && i%5 == 0) continue;
    if(i%3 == 0) continue;
    if(i%5 == 0) continue;

    sum+=i;

}

cout << sum << endl;

return 0;

}