#include <bits/stdc++.h>

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;



int main(){
  ll n;
  cin>>n;
  ll ans=n*(n+1)/2;
  ll x=n/3;
  ans-=3*x*(x+1)/2;
  x=n/5;
  ans-=5*x*(x+1)/2;
  x=n/15;
  ans+=15*x*(x+1)/2;
  cout<<ans<<endl;
}
