import std;

long calc(long n) {
    long sum(long n) { return n * (n + 1) / 2; }

    return sum(n) - 3 * sum(n/3) - 5 * sum(n/5) + 15 * sum(n/15);
}

void main() {
    int n; scan(n);
    writeln(calc(n));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;
