Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/tosh-qaychi-kaltakesak

Rock, scissors, lizard

Medium 1000 ms 64 MB 47%
Share

The game has five moves: t — rock, q — scissors, g — paper, k — lizard, s — Spock. Rules: rock beats scissors and lizard; scissors beat paper and lizard; paper beats rock and Spock; lizard beats Spock and paper; Spock beats scissors and rock. The moves of two players are given. Print $1$ if the first player wins, $2$ if the second player wins, and $0$ if the moves are the same.

Five moves at the corners of a pentagon, arrows from each move to the two it beats; the given pair highlighted

Input

One line with two characters: the first and the second player's moves.

Output

One integer: $1$, $2$ or $0$.

Note

Each character is t, q, g, k or s.

Examples

Input #1
k s
Output #1
1
Input #2
t g
Output #2
2

Sign in to submit a solution

Signing up is free and takes a minute.