#include<iostream>
#include<cstdint>

inline int64_t sum(int64_t x) { return x*(x+1)/2; }

int main() {
  int64_t N; std::cin >> N;
  std::cout << sum(N) - 3*sum(N/3) - 5*sum(N/5) + sum(N/15) << std::endl;
  return 0;
}
