#include <bits/stdc++.h>
using namespace std;
const int daysInMonth[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
          startDay = 5;
int main() {
  int goodDay;
  string type;
  cin >> goodDay >> type >> type;
  int answer = 0;
  if (type == "week") {
    int typeOfDay = startDay;
    int tMonth = 1, tDay = 1;
    while (tMonth <= 12) {
      if (typeOfDay == goodDay) {
        answer++;
      }
      tDay++;
      typeOfDay++;
      if (tDay > daysInMonth[tMonth]) {
        tDay = 1;
        tMonth++;
      }
      if (typeOfDay == 8) {
        typeOfDay = 1;
      }
    }
  } else {
    int tMonth = 1, tDay = 1;
    while (tMonth <= 12) {
      if (tDay == goodDay) {
        answer++;
      }
      tDay++;
      if (tDay > daysInMonth[tMonth]) {
        tDay = 1;
        tMonth++;
      }
    }
  }
  cout << answer;
  return 0;
}
