//
//AtCoder Beginner Contest 162
//B - FizzBuzz Sum 
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define zero(a) memset(a, 0, sizeof(a))

using ll = long long;

int main()
{
    int n;

    cin >> n;

    ll ans = 0;

    rep(i, n){
        if (((i+1)%3 == 0) || ((i+1)%5 == 0)){

        }else{
            ans += (i+1);
        }

    }

    cout << ans << endl;

    return 0;
}
