#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)res=res*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return res;
}
ll inv(ll x){
    return power(x,mod-2);
}
int main(){
    ll t,i;
    ll n;
    cin>>n;
    ll sum=(1+n)*n/2;
    ll t3=n/3,t5=n/5,t15=n/15,s1=3*(1+t3)*t3/2,s2=5*(1+t5)*t5/2,s3=15*(1+t15)*t15/2;
    cout<<sum-s1-s2+s3;
}
