#include <bits/stdc++.h>
using namespace std;
struct State {
  int x, y, d, k;
  State(){};
  State(int x, int y, int d, int k) : x(x), y(y), d(d), k(k){};
};
const int N = (int)1e3 + 10;
const int DX[4] = {0, 1, 0, -1};
const int DY[4] = {1, 0, -1, 0};
int n, m;
char S[N][N];
bool fre[N][N][4][3];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%s", S[i] + 1);
  int sx, sy, tx, ty;
  for (int i = 1; i <= n; ++i)
    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;
      }
    }
  queue<State> Q;
  memset(fre, true, sizeof fre);
  for (int i = 0; i < 4; ++i) {
    Q.push(State(sx, sy, i, 0));
    fre[sx][sy][i][0] = false;
  }
  while (Q.size()) {
    State u = Q.front();
    Q.pop();
    if (u.x == tx && u.y == ty) {
      puts("YES");
      return 0;
    }
    for (int k = 0; k < 4; ++k) {
      int x = u.x + DX[k];
      int y = u.y + DY[k];
      int f = u.k + (u.d != k);
      if (1 <= x && x <= n && 1 <= y && y <= m && S[x][y] != '*' && f <= 2) {
        if (fre[x][y][k][f] == false) continue;
        fre[x][y][k][f] = false;
        Q.push(State(x, y, k, f));
      }
    }
  }
  puts("NO");
  return 0;
}
