import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdlib;

void main() {
    auto N = readln.chomp.to!int;
    long ans = 0;
    foreach (i; 1..N+1) if (i % 3 != 0 && i % 5 != 0) ans += i;
    ans.writeln;
}