/*
      ___           ___                       ___     
     /\__\         /\  \                     /\  \    
    /:/ _/_       /::\  \       ___          \:\  \   
   /:/ /\__\     /:/\:\  \     /\__\          \:\  \  
  /:/ /:/  /    /:/  \:\  \   /:/__/      _____\:\  \ 
 /:/_/:/  /    /:/__/ \:\__\ /::\  \     /::::::::\__\
 \:\/:/  /     \:\  \ /:/  / \/\:\  \__  \:\~~\~~\/__/
  \::/__/       \:\  /:/  /   ~~\:\/\__\  \:\  \      
   \:\  \        \:\/:/  /       \::/  /   \:\  \     
    \:\__\        \::/  /        /:/  /     \:\__\    
     \/__/         \/__/         \/__/       \/__/    
                    ___                                
                   /|  |          _____                
      ___         |:|  |         /::\  \         ___   
     /\__\        |:|  |        /:/\:\  \       /|  |  
    /:/  /      __|:|__|       /:/  \:\__\     |:|  |  
   /:/__/      /::::\__\_____ /:/__/ \:|__|    |:|  |  
  /::\  \      ~~~~\::::/___/ \:\  \ /:/  /  __|:|__|  
 /:/\:\  \         |:|~~|      \:\  /:/  /  /::::\  \  
 \/__\:\  \        |:|  |       \:\/:/  /   ~~~~\:\  \ 
      \:\__\       |:|__|        \::/  /         \:\__\
       \/__/       |/__/          \/__/           \/__/

*/
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
#define IMAX 0x3f3f3f3f
#define LLMAX 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef double db;
inline int read() {
  int x=0,f=1;
  char c=getchar();
  while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
  while(isdigit(c)){x=x*10+c-'0';c=getchar();}
  return x*f;
}
int n;
ll sum;
signed main() {
  n=read();
  rep(i,1,n){
    if(i%3!=0&&i%5!=0){
      sum+=i;
    }
  }
  printf("%lld\n",sum);
  return 0;
}