#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <iterator>
#include <iostream>
#include <sstream>
#include <iterator>
#include <numeric>

using namespace std;


int main() {

    int N;
    cin >> N;

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

        } else if (i % 3 == 0) {

        } else if (i % 5 == 0) {

        } else {
            sum += i;
        }
    }

    cout << sum << endl;
    return 0;

}