#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, a, b, c;
  cin >> n;
  a = n / 3, b = n / 5; c = n / 15;
  cout << n * (n + 1) / 2 - a * (a + 1) / 2 * 3 - b * (b + 1) / 2 * 5 + c * (c + 1) / 2 * 15;
  return 0;
}