#include <bits/stdc++.h>
int mon[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int leap(int y) {
  if (y % 400 == 0) return 1;
  if (y % 100 == 0) return 0;
  if (y % 4 == 0) return 1;
  return 0;
}
int weekday(int y, int m, int d) {
  int yy = m >= 3 ? y : (y - 1);
  int mm = m >= 3 ? (m - 2) : (m + 10);
  int dd = (yy + yy / 4 - yy / 100 + yy / 400 + (int)(2.6 * mm - 0.2) + d) % 7;
  if (dd == 0) dd = 7;
  return dd;
}
int f[8];
int g[32];
void spend(int y1, int m1, int d1, int y2, int m2, int d2) {
  int day = 0;
  mon[2] = 28 + leap(y1);
  while (1) {
    ++day;
    ++f[weekday(y1, m1, d1)];
    ++g[d1];
    if (++d1 > mon[m1]) {
      d1 = 1;
      if (++m1 > 12) {
        m1 = 1;
        mon[2] = 28 + leap(++y1);
      }
    }
    if (y1 == y2 && m1 == m2 && d1 == d2) return;
  }
}
int x;
char s[10];
int main() {
  spend(2016, 1, 1, 2017, 1, 1);
  while (~scanf("%d%*s%s", &x, s)) {
    if (s[0] == 'w') {
      printf("%d\n", f[x]);
    } else {
      printf("%d\n", g[x]);
    }
  }
  return 0;
}
