#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,summ=0;
    cin>>t;
    for(int i=1;i<=t;i++){
        if(i%3==0 && i%5==0)
            continue;
        else if(i%3==0)
            continue;
        else if(i%5==0)
            continue;
        else
            summ+=i;
    }
    cout<<summ;
}
