#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    ll N; cin >> N;
    ll a = N/15;
    ll b = N/3;
    ll c = N/5;
    cout << N*(N+1)/2 + 15*a*(a+1)/2 - 3*b*(b+1)/2 - 5*c*(c+1)/2 << endl;
    return 0;
}
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  int n;

  cin >> n;
  lll sum = 0;
  for(ii=1;ii<=n;ii++){
    if((ii % 3 == 0) &&
       (ii % 5 == 0)){

    }
    else if(ii % 3 == 0){

    }
    else if(ii % 5 == 0){

    }
    else{
      sum += ii;
    }

  }

  cout << sum << endl;
  
  return 0;
}
