#include<stdio.h>
#include<stdlib.h>
#define ll long long
int  main(){
    ll n;
    scanf("%lld",&n);
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0)
            ans += i;
    }
    printf("%lld\n",ans);
    return 0;
}