#include <bits/stdc++.h>
using namespace std;
int N, M;
int G[1024][1024];
int V[1024][1024];
struct state {
  int posx, posy, j, d;
};
bool bfs(int xi, int yi, int xf, int yf) {
  queue<struct state> q;
  struct state curr;
  curr.posx = xi;
  curr.posy = yi;
  curr.j = 0;
  curr.d = -1;
  q.push(curr);
  while (q.size()) {
    curr = q.front();
    q.pop();
    if (curr.posx == xf && curr.posy == yf) return true;
    for (int i = -1; i < 2; i++) {
      for (int j = -1; j < 2; j++)
        if ((i == 0 && j != 0) || (i != 0 && j == 0)) {
          int npx = curr.posx + i, npy = curr.posy + j;
          if (npx < 0 || npx >= N) {
            continue;
          }
          if (npy < 0 || npy >= M) {
            continue;
          }
          if (!G[npx][npy]) {
            continue;
          }
          struct state newst;
          newst.posx = npx;
          newst.posy = npy;
          newst.j = curr.j;
          if (i == -1) {
            if (curr.d != -1 && curr.d != 0) newst.j++;
            newst.d = 0;
          }
          if (i == 1) {
            if (curr.d != -1 && curr.d != 1) newst.j++;
            newst.d = 1;
          }
          if (j == -1) {
            if (curr.d != -1 && curr.d != 2) newst.j++;
            newst.d = 2;
          }
          if (j == 1) {
            if (curr.d != -1 && curr.d != 3) newst.j++;
            newst.d = 3;
          }
          if (newst.j < 3 && V[npx][npy] > newst.j) {
            V[npx][npy] = newst.j;
            q.push(newst);
          }
        }
    }
  }
  return false;
}
int main(void) {
  cin >> N >> M;
  int xi, yi, xf, yf;
  memset(V, 2, sizeof(V));
  for (int i = 0; i < N; i++) {
    string line;
    cin >> line;
    for (int j = 0; j < M; j++) {
      if (line[j] == 'S') {
        xi = i;
        yi = j;
      } else if (line[j] == 'T') {
        xf = i;
        yf = j;
      }
      G[i][j] = (line[j] == '.') || (line[j] == 'T');
    }
  }
  if (bfs(xi, yi, xf, yf)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
