Under construction

Still being built. Things may change

Poker

Time limit2sMemory limit1024 MB

Summary
Given Loki's money and the small blind, count the rounds until Loki runs out when he folds every time and the blinds swap after each round.
Level

Easy3 of 10

Topics
Math, Simulation
Solved
No attempts yet

Statement

Loki is a very sly and cunning god, but even he makes mistakes. Thor found out who shaved the head of Loki's wife and now demands compensation. Loki offers him a deal: in the final game of Asgard poker he will fold at every chance, so Thor wins.

In each round of Asgard poker, three cards are placed on the table, and after each of the four phases one more card is added. Before each round, a player posts either the small blind or the big blind, which is twice the small blind. After each round, the blind types of the players swap. If a player has less money than the blind, the player posts all of it. After each phase, a player may double the bet if they have enough money, or fold and stop playing. If a player folds, all posted money goes to the other player, and the folding player loses all the money they posted. At the end of the round, the players reveal their cards. A hand is made from any five of a player's cards and the cards on the table. The player with the stronger hand wins and takes all the money posted in that round.

Loki finds it boring to watch Thor win, so he wants to know how many rounds the game will have in total.

Input

The first line contains two integers xx and bb (1≤x,b≤1091 \le x, b \le 10^9), the amount of money Loki has before the game starts and the size of the small blind. The second line contains the letter L if Loki posts the first small blind, or T if Thor does. Thor's money can be treated as enough for any bet.

Output

Print the number of rounds in the game on a single line.

Examples2

  1. Example 1

    Input
    7 2
    L
    
    Expected output
    3
    
  2. Example 2

    Input
    7 2
    T
    
    Expected output
    3