function Main (N) {
  N = parseInt(N, 10);
  var ans = 0;
  for (var i = 1; i <= N; i++) {
    if (i%3 != 0 && i%5 != 0) {
      ans += i
    }
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));