#include <bits/stdc++.h>
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;
using namespace std;

int main(){
  ll N;
  scanf("%lld", &N);

  ll sum=0;
  REP(ll, i, 1, N+1){
    if(i%3!=0 && i%5!=0) sum += i;
  }

  printf("%lld",sum);
}