#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int64_t)N;i++)
typedef int64_t LL;
int main()
{
  int N;
  LL sum=0;
  cin>>N;
  rep(i,N){if((i+1)%3>0||(i+1)%5>0)sum+=i+1;}
  return cout<<sum<<endl,0;
}