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

int main() {
  int N;
  cin >> N;
  
  long sum = N * (1 + N) / 2;
  int N3 = N / 3;
  int N5 = N / 5;
  int N15 = N / 15;
  
  long ans = sum - N3 * (1 + N3) / 2 * 3 - N5 * (1 + N5) / 2 * 5 + N15 * (1 + N15) / 2 * 15;
  cout << ans << endl;
}
