#include <iostream>
using namespace std;

int main() {
	int64_t N = 0,s = 0,t = 0,u = 0;
	cin >> N;
    s = N / 3;
    t = N / 5;
    u = N / 15;
    cout << (N * (N + 1) / 2) - (s * (3 * (s + 1)) / 2) - (t * (5 * (t + 1)) / 2) + (u * (15 * (u + 1)) / 2) << endl;
  	return 0;
}
