#include <iostream>
#include <string>
#include <cmath>


using namespace std;


int main(){
    long long a,b,c,N,sum;
    cin >> N;
    a=(N-N%3)/3;
    b=(N-N%5)/5;
    c=(N-N%15)/15;
    sum=(N*(N+1)/2)-3*(a*(a+1)/2)-5*(b*(b+1)/2)+15*(c*(c+1)/2);
    cout << sum << endl;
    //float ;
    return 0;
}