#include<bits/stdc++.h>
#define pb push_back
#define mod int(1e9+7)
#define N int(2e5+100)
#define ll long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define si second
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
   int n;
   cin>>n;
   ll sum=0*1ll;
   for(int i=1;i<=n;i++){
      if(i%3&&i%5){
         sum+=1ll*i;
      }
   }
   cout<<sum<<'\n';
   return 0;
}
