#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

long long N,i,j,k,ans;

char S[10];

int main()
{
  cin >>N;
  
  for(i=1;i<=N;i++)
  {
    if(i%3!=0 && i%5!=0) ans+=i;
  }
  
  cout <<ans;
  
  
}