#include <bits/stdc++.h>

inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
long long ans;
int n;
int main() {
    std::cin >> n;
    for (int i = 1; i <= n; ++i)
    	if (i % 3 != 0 && i % 5 != 0) ans += (long long)i;
    std::cout << ans << '\n';

}


