#include<iostream.h>
using namespace std;

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define MOD 1000000007

const int MAX_M = 100000;


int main(){
  ll n; 
  //string s;
  cin >> n;
  
  ll ans = 0;
  rep(i,1,n+1){
    if((i%3 != 0) && (i%5 != 0))
      ans += i;
  }
  
  cout << ans << endl;
}