#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1100;
struct node {
  int x, y, dir, turn;
  node(int a, int b, int c, int d) {
    x = a;
    y = b;
    dir = c;
    turn = d;
  }
};
char a[N][N];
queue<node> q;
int dp[N][N][4][2];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int sx, sy;
  int tx, ty;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf(" %c", &a[i][j]);
      if (a[i][j] == 'S') {
        sx = i;
        sy = j;
      }
      if (a[i][j] == 'T') {
        tx = i;
        ty = j;
      }
    }
  }
  q.push(node(sx, sy, 0, 0));
  q.push(node(sx, sy, 1, 0));
  q.push(node(sx, sy, 2, 0));
  q.push(node(sx, sy, 3, 0));
  while (!q.empty()) {
    node top = q.front();
    q.pop();
    dp[top.x][top.y][top.dir][top.turn] = 1;
    for (int i = 0; i < 4; i++) {
      int turn = min(abs(top.dir - i), 4 - abs(top.dir - i));
      int nx = top.x + dx[i];
      int ny = top.y + dy[i];
      if (nx < 0 || nx >= n || ny < 0 || ny >= m) continue;
      if (turn + top.turn > 2) continue;
      if (dp[nx][ny][i][turn + top.turn] == 1 || a[nx][ny] == '*') continue;
      q.push(node(nx, ny, i, turn + top.turn));
      dp[nx][ny][i][turn + top.turn] = 1;
      if (nx == tx && ny == ty) {
        printf("YES\n");
        return 0;
      }
    }
  }
  int ok = 0;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j <= 2; j++) {
      if (dp[tx][ty][i][j] == 1) ok = 1;
    }
  }
  if (ok)
    printf("YES\n");
  else
    printf("NO\n");
}
