#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1100;
struct node {
  int x, y, dir, vir;
  node(int a, int b, int c, int d) {
    x = a;
    y = b;
    dir = c;
    vir = d;
  }
};
bool operator<(node a, node b) { return a.vir < b.vir; }
char a[N][N];
priority_queue<node> pq;
int dp[N][N][5];
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;
      }
      for (int k = 0; k < 4; k++) {
        dp[i][j][k] = INF;
      }
    }
  }
  for (int i = 0; i < 4; i++) {
    dp[sx][sy][i] = 0;
    pq.push(node(sx, sy, i, 0));
  }
  while (!pq.empty()) {
    node top = pq.top();
    pq.pop();
    if (top.vir <= dp[top.x][top.y][top.dir]) {
      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 (dp[top.x][top.y][top.dir] + turn > 2) continue;
        if (a[nx][ny] == '*') continue;
        if (dp[top.x][top.y][top.dir] + turn < dp[nx][ny][i]) {
          dp[nx][ny][i] = dp[top.x][top.y][top.dir] + turn;
          pq.push(node(nx, ny, i, dp[nx][ny][i]));
        }
      }
    }
  }
  int ok = 0;
  for (int i = 0; i < 4; i++) {
    if (dp[tx][ty][i] < 3) ok = 1;
  }
  if (ok)
    printf("YES\n");
  else
    printf("NO\n");
}
