    //Bismillah hirrahmanir Rahim
    #include<bits/stdc++.h>
    #define ll long long
    #define pb push_back
    #define dbug printf("I am here\n");
    #define Fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    using namespace std;

main() {
    Fast
  ll int a;
 cin>>a;
ll sum=0;
 for(int i=1;i<=a;i++){
   if(i%3!=0 && i%5!=0){
      // cout<<i<<endl;
        sum+=i;
   }
 }
   cout<<sum<<endl;
	return 0;
}
