#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
char s[1002][1002];
short dp[4][1002][1002];
int Sx, Sy, Tx, Ty;
int qx[14400002];
int qy[14400002];
short qd[14400002];
int qh, qt;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
    for (int j = 1; j <= m; j++) {
      if (s[i][j] == 'S') {
        Sx = i;
        Sy = j;
      }
      if (s[i][j] == 'T') {
        Tx = i;
        Ty = j;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int d = 0; d < 4; d++) dp[d][i][j] = 5;
  int qh = 1;
  for (int d = 0; d < 4; d++) {
    dp[d][Sx][Sy] = 0;
    qt++;
    qx[qt] = Sx;
    qy[qt] = Sy;
    qd[qt] = d;
  }
  while (qh <= qt) {
    int x = qx[qh];
    int y = qy[qh];
    int d = qd[qh];
    qh++;
    for (int dd = 0; dd < 4; dd++) {
      if (dp[d][x][y] + (d != dd) > 2) continue;
      int nx = x + dx[dd];
      int ny = y + dy[dd];
      if (nx < 1 || nx > n || ny < 1 || ny > m) continue;
      if (s[nx][ny] == '*') continue;
      if (dp[d][x][y] + (d != dd) < dp[dd][nx][ny]) {
        dp[dd][nx][ny] = dp[d][x][y] + (d != dd);
        qt++;
        qx[qt] = nx;
        qy[qt] = ny;
        qd[qt] = dd;
      }
    }
  }
  for (int d = 0; d < 4; d++) {
    if (dp[d][Tx][Ty] <= 2) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}
