// Example program
#include <iostream>
#include <string>

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