#include <bits/stdc++.h>
#include<string>
#define mod 1000000007
using ll = long long;
using namespace std; 

int main(){
    ll n; cin >> n;
    ll ans=0;
    ll s=n/3;
    ll a=n/5;
    ll d=n/15;
    ans=(1+n)*n/2;
    ans=ans-(3+s*3)*s/2-(5+a*5)*a/2+(15+d*15)*d/2; 
    cout << ans << "\n";
}


#include <stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    long long int ans=0;
    for(int i=1;i<=n;i++){
       if(i%3==0 ||i%5==0){
           continue;
       }
       ans +=i;
    }
    printf("%lld\n", ans);
    return 0;
}