#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    long long dp[1000000] = {0};
    int n;
    cin >> n;

    dp[0] = 1;
    
    for (int i = 2;i <= n;i++)
    {
        if (i % 3 == 0 || i % 5 == 0)
        {
            dp[i - 1] = dp[i -2];
        }
        else
        {
            dp[i - 1] = dp[i - 2] + i;
        }
    }

    cout << dp[n - 1] << endl;
    
    return 0;
}
