#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
int main(int argc, char *argv[])
{
    int n;
    ll sum = 0;

    std::cin >> n;

    for (int i = 1; i <= n; i++) {
        if ((i % 5 != 0) && (i % 3 != 0)) {
            sum += i;
        }
    }

    std::cout << sum << std::endl;

    return 0;
}
