#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(){
    long long sum;
    long long N;
    cin >> N;
    long long tmp = N/15;
    
    sum = N*(1+N)/2;
    sum -= tmp*(60+60+105*(tmp-1))/2;

    for(int i=N/15*15+1; i<=N; ++i){
        if(i%3==0||i%5==0){
            sum -= i;
        }
    }
    cout <<sum<<endl;
    return 0;
}