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

int main() {

	int n;
    cin >> n;
  
  	long long sum = 0;
  	int i = 1;
  
  	while ( i <= n ){
      if ( i % 3 != 0 || i % 5 != 0 ){
        sum += i;
      }
      i++;
    }
 
	cout << sum << endl;
  
}

