#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=1;i<=(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  ll n,ans=0;
  cin>>n;
  rep(i,n){
    if(i%3!=0){
      if(i%5!=0)ans+=i;
    }
  }

  cout<<ans;
  return 0;
}
