// Days (A), by Errichto
#include<bits/stdc++.h>
using namespace std;
int t[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
int x;
scanf("%d", &x);
char sl[15];
scanf("%s", sl);
scanf("%s", sl);
if(sl[0] == 'w') {
int current = 5;
int ans = 0;
for(int i = 0; i < 366; ++i) {
if(current == x) ++ans;
++current;
if(current > 7) current = 1;
}
printf("%d\n", ans);
return 0;
}
int c = 0;
for(int i = 0; i < 12; ++i) c += x <= t[i];
printf("%d\n", c);
return 0;
}
Ly8gRGF5cyAoQSksIGJ5IEVycmljaHRvCiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgdFsxMl0gPSB7MzEsIDI5LCAzMSwgMzAsIDMxLCAzMCwgMzEsIDMxLCAzMCwgMzEsIDMwLCAzMX07CgppbnQgbWFpbigpIHsKCWludCB4OwoJc2NhbmYoIiVkIiwgJngpOwoJY2hhciBzbFsxNV07CglzY2FuZigiJXMiLCBzbCk7CglzY2FuZigiJXMiLCBzbCk7CglpZihzbFswXSA9PSAndycpIHsKCSAgICBpbnQgY3VycmVudCA9IDU7CgkgICAgaW50IGFucyA9IDA7CgkgICAgZm9yKGludCBpID0gMDsgaSA8IDM2NjsgKytpKSB7CgkgICAgICAgIGlmKGN1cnJlbnQgPT0geCkgKythbnM7CgkgICAgICAgICsrY3VycmVudDsKCSAgICAgICAgaWYoY3VycmVudCA+IDcpIGN1cnJlbnQgPSAxOwoJICAgIH0KCSAgICBwcmludGYoIiVkXG4iLCBhbnMpOwoJCXJldHVybiAwOwoJfQoJaW50IGMgPSAwOwoJZm9yKGludCBpID0gMDsgaSA8IDEyOyArK2kpIGMgKz0geCA8PSB0W2ldOwoJcHJpbnRmKCIlZFxuIiwgYyk7CglyZXR1cm4gMDsKfQo=