#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N = 0;
  int ans = 0;
  cin >> N;
  for(int n = 1 , n <= N , n++){
    if( n % 3 != 0 || n % 5 != 0)
      ans = ans + n;
    
  }
  cout << ans;
}