#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, a, dir;
};
char r[1001][1001];
int n, m, vis[4][1001][1001];
int a[4] = {-1, 0, 0, 1}, b[4] = {0, 1, -1, 0};
queue<node> q;
int bfs() {
  while (!q.empty()) {
    node f = q.front();
    if (r[f.x][f.y] == 'T') return f.a;
    q.pop();
    for (int i = 0; i < 4; i++)
      if (f.dir != i && i + f.dir != 3) {
        int nx = f.x + a[i], ny = f.y + b[i];
        while (nx >= 1 && ny >= 1 && nx <= n && ny <= m && r[nx][ny] != '*' &&
               !vis[i][nx][ny]) {
          node t;
          t.x = nx, t.y = ny, t.a = f.a + 1, t.dir = i;
          q.push(t);
          vis[i][nx][ny] = 1;
          nx += a[i], ny += b[i];
        }
      }
  }
  return 3;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> r[i][j];
      if (r[i][j] == 'S') {
        node t;
        t.x = i, t.y = j, t.a = -1, t.dir = -1;
        q.push(t);
      }
    }
  if (bfs() <= 2)
    cout << "YES";
  else
    cout << "NO";
}
