#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  ll res = 0;
  for (int i = 1; i <= n; i++){
    if (i % 3 != 0 && i % 5 != 0)
      res += i;
  }

  cout << res << endl;
  

  return 0;
}
