eolymp
bolt
Try our new interface for solving problems

Thief

Time limit 1 second
Memory limit 128 MiB

A cop is pursuing a thief in a rectangular h * w grid. Both thief and cop occupy one cell of the grid. Initially they are placed in it somehow, and then make moves in turn. At each move one must go from a cell to any of the cells adjacent to it side-by-side. Note that it's not allowed to stay in the same cell. It's also not allowed to move outside the grid.

The cop catches the thief if they're in the same cell. The aim of the cop is to catch the thief as fast as possible, the aim of the thief is not to be caught, or at least to be free for as many moves as possible. They both see each other and the walls of the grid, so they always know the coordinates of themselves and of each other.

If both players play optimally, will the cop catch the thief, and if he will, after which move it will happen? (moves are numbered starting from 1, for example, if the cop moves first, then move 1 is the cop's move, move 2 is the thief's move, move 3 is the cop's move, etc).

Input data

The first line contains two integers h and w (1h, w5 * 10^8), denoting the number of rows and columns in the grid, respectively. The rows are numbered 1 through h, the columns are numbered 1 through w.

The second line contains two integers R[c] and C[c] (1R[c]h, 1C[c]w), denoting the row and column of the cell where the cop resides initially.

The third line contains two integers R[t] and C[t] (1R[t]h, 1C[t]w), denoting the row and column of the cell where the thief resides initially.

Initial positions of the cop and the thief differ.

The fourth line contains either the letter C (capital English letter C) if the cop moves first, or the letter T (capital English letter T) if the thief moves first.

Output data

If the cop can catch the thief with both of them playing optimally, output the number of the move after which it will happen. Otherwise, output 0 (zero).

Examples

Input example #1
2 2
1 2
2 1
C
Output example #1
0
Input example #2
2 2
1 2
2 1
T
Output example #2
2
Source 2007 Петрозаводск, Petr Mitrichev Contest 2, Январь 30, Задача J