#include <bits/stdc++.h>

using namespace std;

int64_t f(int64_t n){
    int64_t ans=0;
    
ans = (1+n)*n/2;

    return ans;
}

int main(){
    int64_t n,ans=0;
    cin >>n;
    ans=f(n) - f(n/3) *3 - f(n/5)*5 + f(n/15)*15; 
    cout << ans <<endl;

}