This page is still under construction.

Parts of this page are still being built. What you see may change.

Tournament Selection

Time limit2sMemory limit512 MB

Summary
Count wins among six game results and print the group number 1, 2, or 3, or -1 if there are no wins.
Level

Easy1 of 10

Topics
Implementation, String
Solved
No attempts yet

Problem

Each player in a tournament plays six games. There are no ties. The tournament director assigns each player to a group from the game results:

  • a player who wins 5 or 6 games goes to Group 1;
  • a player who wins 3 or 4 games goes to Group 2;
  • a player who wins 1 or 2 games goes to Group 3;
  • a player who wins no games is eliminated from the tournament.

Write a program that determines which group a player is assigned to.

Input

The input consists of six lines. Each line holds one letter: W for a win or L for a loss.

Output

Print the group number the player is assigned to, one of 1, 2, or 3. Print -1 if the player is eliminated.

Examples2

  1. Example 1

    Input
    W
    L
    W
    W
    L
    W
    
    Expected output
    2
    
  2. Example 2

    Input
    L
    L
    L
    L
    L
    L
    
    Expected output
    -1