#include <iostream>

using namespace std;

int main() {
    int x;
    cin>>x;
    long long int fizz=0;
    for(int i=0;i<=x;++i){
        if(i%3==0 || i%5==0 ||i%15==0)
        continue;
        fizz+=i;
    }
    cout<<fizz;
}