#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin>>N;
    int n3=N/3, n5=N/5, n15=N/15;
    int total=(1+N)*N/2;
    total-=(2*3+(n3-1)*3)*n3/2;
    total-=(2*5+(n5-1)*5)*n5/2;
    total+=(2*15+(n15-1)*15)*n15/2;
    cout<<total<<endl;
}
