#include <bits/stdc++.h>
int main() {
  int a, b, c = 0, i, n;
  char str[100], s[100], k[100];
  scanf(" %[^\n]", str);
  sscanf(str, "%d %s %s", &a, k, s);
  if (!strcmp(s, "week")) {
    n = 5;
    for (i = 1; i <= 366; i++) {
      if (n == a) c++;
      if (n == 7)
        n = 1;
      else
        n++;
    }
    printf("%d\n", c);
  } else if (!strcmp(s, "month")) {
    if (a == 30)
      printf("11\n");
    else if (a == 31)
      printf("7\n");
    else
      printf("12\n");
  }
  return 0;
}
