import std;

void main()
{
  const N = readln().chomp().to!long();
  
  ulong sum = 0;
  foreach (i; 1 .. N + 1)
  {
    if (i % 3 == 0) continue;
    if (i % 5 == 0) continue;
    sum += i;
  }
  
  writeln(sum);
}