Poker Hand

Interview

Time limit2sMemory limit512 MB

Summary
Given five distinct cards, report the largest number of cards sharing one rank.
Level

Easy2 of 10

Topics
Hash map, Implementation
Solved
No attempts yet

Problem

You are given a five-card hand drawn from a standard 52-card deck. The strength of your hand is the maximum value k such that there are k cards in your hand that have the same rank.

Compute the strength of your hand.

Input

The input consists of a single line, with five two-character strings separated by spaces.

The first character in each string is the rank of the card, and is one of A23456789TJQK. The second character in the string is the suit of the card, and is one of CDHS.

You may assume all the strings are distinct.

Output

Output, on a single line, the strength of your hand.

Examples3

  1. Example 1

    Input
    AC AD AH AS KD
    
    Expected output
    4
    
  2. Example 2

    Input
    2C 4D 4H 2D 2H
    
    Expected output
    3
    
  3. Example 3

    Input
    AH 2H 3H 4H 5H
    
    Expected output
    1