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

int main(){
    long long N; cin >> N;
    long long sum = (N*(N+1))/2;
    long long three = N/3;
    long long five = N/5;
    long long tf = N/15;
    sum -= 3*(three*(three+1))/2 + 5*(five*(five+1))/2;
    sum += 15*(tf*(tf+1))/2;
    cout << sum << endl;
}