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

int main() {
  int64_t a;
  cin >> a;
  
  int64_t sum, b, c, d;
  sum = a*(a+1)/2;
  b = a/3;
  b = 3*b*(b+1)/2;
  c = a/5;
  c = 5*c*(c+1)/2;
  d = a/15;
  d = 15*d*(d+1)/2;
  
  sum = sum - b - c + d;
  cout << sum;
}






