#include <bits/stdc++.h>
using namespace std;
char s[2001][2001];
int v[2001][2001];
int d[4][2] = {-1, 0, 0, -1, 1, 0, 0, 1};
int n, m;
void bfs(int sx, int sy) {
  memset(v, 0, sizeof v);
  v[sx][sy] = 1;
  queue<int> p;
  p.push(sx);
  p.push(sy);
  for (int i = 0; i < 4; i++) {
    int x = sx + d[i][0];
    int y = sy + d[i][1];
    while (x >= 0 && x < n && y >= 0 && y < m && s[x][y] != '*') {
      v[x][y] = 1;
      p.push(x);
      p.push(y);
      x += d[i][0];
      y += d[i][1];
    }
  }
  while (!p.empty()) {
    sx = p.front();
    p.pop();
    sy = p.front();
    p.pop();
    if (s[sx][sy] == 'T') {
      puts(v[sx][sy] <= 3 ? "YES" : "NO");
      return;
    }
    if (v[sx][sy] >= 3) continue;
    for (int i = 0; i < 4; i++) {
      int x = sx + d[i][0];
      int y = sy + d[i][1];
      while (x >= 0 && x < n && y >= 0 && y < m && s[x][y] != '*') {
        if (v[x][y] == 0) {
          v[x][y] = v[sx][sy] + 1;
          p.push(x);
          p.push(y);
        } else if (v[x][y] < v[sx][sy] + 1)
          break;
        x += d[i][0];
        y += d[i][1];
      }
    }
  }
  puts("NO");
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++)
      if (s[i][j] == 'S') {
        bfs(i, j);
        return 0;
      }
  }
}
