#include<bits/stdc++.h>
#include<cstring>

#define ll long long
using namespace std;
long long power(ll  x, ll n){
    if(n==0)return 1;
    ll temp=power(x,n/2);
    if(n%2==0)return temp*temp;
    else return x*temp*temp;

}
ll max(ll a,ll b){
    return a>b?a:b;

}

ll max(ll a,ll b,ll c){
    return max(max(a,b),c);
}
ll min(ll x,ll  y){
    return x+y-max(x,y);
}
ll min(ll x,ll y,ll z){
    return min(min(x,y),z);

}



void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

bool f(ll x,ll y){
    return x>y;

}


int main(){
    ll n;
    cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0)sum+=i;



    }

cout<<sum;


    return 0;
}




































