import "dart:io";

void main(List<String> args) {
  int n = int.parse(stdin.readLineSync());
  int sum = 0;

  for (var i = 1; i <= n; i++) {
    if (i%3 != 0 && i%5 != 0) sum += i;
  }

  print(sum);
}