#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323846264338327950L

int main() {
	int N;
	cin >> N;
	long long sum = 0;
	for (int ii = 1; ii <= N; ii++) {
		if (ii % 3 == 0 && ii % 5 == 0) {
			continue;
		}
		if (ii % 3 == 0 || ii % 5 == 0) {
			continue;
		}
		sum += ii;
	}
	cout << sum << endl;
}
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int main() {
	string d[7] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	string x;
	cin >> x;
	for (int i = 0; i < 7; ++i) {
		if (d[i] == x) {
			PRI(7 - i);
			return 0;
		}
	}
	return 0;
}