#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
    ll n,a,b,c;
    cin >> n;
    a=n/3;
    b=n/5;
    c=n/15;
  if(n%2==0){
    n=n/2*(n+1);
  }else{
    n=(n+1)/2*n;
  }
    a=a*(a+1)/2;
    b=b*(b+1)/2;
    c=c*(c+1)/2;
    cout << n-a*3-b*5+c*15;

}
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl

void solve() {
  ll n;
  cin >> n;
  ll sm = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 5 == 0)
      continue;
    sm += i;
  }
  cout << sm << '\n';
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ll test = 1;
  // cin >> test;
  while (test--) {
    solve();
  }
  return 0;
}
