#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    long sum = 0;
    
    scanf("%d",&N);
    
    for(int i = 1; i <= N; i++)
    {
        if(i % 3 != 0 && i % 5 != 0)
        {
            sum += i;
        }
    }
    
    printf("%ld\n",sum);
}
