  #include <bits/stdc++.h>
   using namespace std;
   using pii = pair<int, int>;
   using ll = long long;
   #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
   const ll MOD = 1000000007;
   const ll INF = 1LL << 60;

   int main() {
     ll N, ans = 0;
     cin >> N;

     for (ll i = 1; i < N + 1; i++) {
       if (i % 3 != 0 && i % 5 != 0) ans += i;
     }

     cout << ans << endl;
   }
