#include <bits/stdc++.h>
using namespace std;
char t[20];
int x;
int mon[15] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void week() {
  int le = 366 - 3 - 6, sum = 0;
  if (x >= 5 && x <= 7) sum++;
  if (x >= 1 && x <= 6) sum++;
  sum += le / 7;
  cout << sum << endl;
}
void month() {
  int sum = 0;
  for (int i = 1; i <= 12; i++)
    if (mon[i] >= x) sum++;
  cout << sum << endl;
}
int main() {
  gets(t);
  if (t[1] == ' ')
    x = t[0] - '0';
  else
    x = 10 * (t[0] - '0') + t[1] - '0';
  if (t[5] == 'w')
    week();
  else
    month();
}
