#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n;
  	cin >> n;
  	ll sum=0ll;
  	for(ll i=1; i<=n; i++){
      if(n%3 != 0 && n%5!=0) sum += i;
    }
  	cout << sum;

    return 0;
}
