
#include <bits/stdc++.h>
//#in0clude  <iostream>
 using namespace std;
 
#define IOS         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define mem(a,v)    memset((a), (v), sizeof (a))
#define FOR(i,a,n)  for(int i = (a); i<(n); ++i) 
#define mp(a , b)   make_pair(a , b)
#define pb(a)       push_back(a)

#define anal         '\n'

#define M 1000000007 
typedef long long ll;

 
 




int main(){
     
    IOS;
    
   // freopen("input.in", "r", stdin);
   // freopen("output.in", "w", stdout);
     


    int n;
    cin>>n;
    
     ll sum =0;

     FOR(i,1,n+1){
     	if(i%3 !=0 && i%5 !=0)
     		sum += i;
     }

     cout<<sum;
  return  0 ;
   	    
 }