Training Site
Sideways banner

Mind Reader

Input: Standard Input (stdin)
Output: Standard Output (stdout)
Memory limit: 50 megabytes
Time limit: 1.0 seconds

Sam isn't good at maths but wants to win at a card game called Mind Reader.

Every card has a suit and a number. In Mind Reader the order of the suits from lowest to highest is:

spades, clubs, diamonds, hearts

And the order of the 'numbers' from low to high is:

2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace

In Mind Reader the cards' values are ranked first by their suit, and then, for cards of the same suit, by their number. Sam needs to know how many cards in the pack are higher in value than his card.

Input

  • The first line will be the number of Sam's card - one of:
    2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A
  • The second line will be the suit of Sam's card - one of:
    spades, clubs, diamonds, hearts

Output

Output a single integer giving the number of cards in the pack valued higher than Sam's card.

Subtasks

  • Subtask 1 (+30%): All cards are in the suit of hearts
  • Subtask 2 (+70%): No further constraints apply

Sample Explanations

Sample 1

In this case the card is the 10 of hearts. The cards higher than it are the Jack, Queen, King, and Ace of hearts. Thus, the answer is 4.

Sample 2

In this case the card is the King of diamonds. The cards higher than it are the Ace of diamonds, and all the cards in the suit of hearts. Thus, the answer is 14. This sample is part of Subtask 2.

  • Sample Input 1

    10
    hearts
    

    Sample Output 1

    4
    
  • Sample Input 2

    K
    diamonds
    

    Sample Output 2

    14