#include <bits/stdc++.h>
#include <set>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef char chr;
typedef double  dbl;
typedef long long int lld;
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
double getComb (double n, double x){
    if (x > n){
        return 0;
    }
    else{
        double r = 1.0;
        for(double i = 1.0; i<=x;i+=1){
            double a = n-i+1;
            double b = a / i;
            r*=b;
        }
        return r;
    }
}
int main () {
    FastIO
    lld n, i;
    cin >> n;
    lld s =0;
    for(i = 1; i<=n; i+=1){
    	if (i%3 == 0 || i%5 == 0){
    		
    	}
    	else{
    		s += i;
    	}
    }
    cout << s << "\n";
    return 0;
}