/**
*    author:  Dooloper
*    created: 12.04.2020 20:51:07
**/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>

using namespace std;
typedef unsigned long ll;

int main() {
   cin.tie(0);
    ll N;cin>>N;
    ll sum = 0;

    for (int i = 0; i < N; i++)
    {
        if(i % 3 == 0 || i % 5 == 0){

        }else{
            sum += i;
        }
    }
    

    cout<<sum << endl;
   return 0;
}