#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a;
    cin >> a;
    int i = 1;
    int k = 0;
    while(i<a){
        if(i%3 != 0 && i%5 != 0){
            k += i;
            
        }else{
            
        }
        i++;
    }
   cout << k << endl; 
   
}
