#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<vector>

using namespace std;

int main(){
    long long sum = 0;
    long long n = 0;
    cin>>n;

    int f = n/3;
    int b = n/5;
    int fb = n/15;
    sum = n*(n+1)/2;
    sum -= 3*(f*(f+1)/2);
    sum -= 5*(b*(b+1)/2);
    sum += 15*(fb*(fb+1)/2);
    cout<<sum<<endl;

    return 0;
}
