#include <bits/stdc++.h>
#pragma comment(linker, "/stack:640000000")
using namespace std;
vector<int> v;
int fx[] = {0, 0, -1, 1, -1, 1, 1, -1};
int fy[] = {1, -1, 0, 0, 1, 1, -1, -1};
int row, col;
int vis[1010][1010][7][7], flag = 0, x, y;
char input[1010][1010];
void dfs(int sx, int sy, int dir, int turn) {
  if (flag) return;
  vis[sx][sy][dir][turn] = 1;
  if (sx == x && y == sy) flag = 1;
  int tx = sx + fx[dir], ty = sy + fy[dir];
  if (tx >= 0 && tx < row && ty >= 0 && ty < col &&
      vis[tx][ty][dir][turn] == 0 && input[tx][ty] != '*')
    dfs(tx, ty, dir, turn);
  if (turn > 0) {
    for (int i = 0; i < 4; i++) {
      if (i == dir) continue;
      int tx = sx + fx[i], ty = sy + fy[i];
      if (tx >= 0 && tx < row && ty >= 0 && ty < col &&
          vis[tx][ty][i][turn - 1] == 0 && input[tx][ty] != '*')
        dfs(tx, ty, i, turn - 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  while (cin >> row >> col) {
    int sx, sy;
    flag = 0;
    for (int i = 0; i < row; i++) {
      for (int j = 0; j < col; j++) {
        cin >> input[i][j];
        if (input[i][j] == 'S') {
          sx = i;
          sy = j;
        }
        if (input[i][j] == 'T') {
          x = i;
          y = j;
        }
      }
    }
    for (int i = 0; i < 4; i++) {
      if (!flag) dfs(sx, sy, i, 2);
    }
    if (flag == 1)
      cout << "YES" << '\n';
    else
      cout << "NO" << '\n';
  }
  return 0;
}
