#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll n;
  cin >> n;
  ll sum=0;
  ll j=1;
  for(int i=0;i<n;i++) {
    if(j%3!=0 && j%5!=0) {
      sum+=j;
      j+=1;}
    else {
      sum+=0;
      j+=1;}
    }
  return 0;
  }
      