#include <bits/stdc++.h>
using namespace std;
struct vertex {
  int y, x, dir, cnt;
};
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};
int n, m, starty, startx, finishy, finishx;
char graph[1005][1005];
int ans[1005][1005];
queue<vertex> q;
int main() {
  cin >> n >> m;
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= m + 1; j++) {
      graph[i][j] = '*';
      ans[i][j] = 1e9;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> graph[i][j];
      if (graph[i][j] == 'S') {
        starty = i;
        startx = j;
      }
      if (graph[i][j] == 'T') {
        finishy = i;
        finishx = j;
      }
    }
  }
  ans[starty][startx] = 0;
  q.push({starty, startx, -1, -1});
  while (!q.empty()) {
    int cury = q.front().y;
    int curx = q.front().x;
    int curdir = q.front().dir;
    int curcnt = q.front().cnt;
    if (graph[cury][curx] == 'T' && 2 >= curcnt) {
      cout << "YES";
      return 0;
    }
    q.pop();
    if (curcnt > 2) {
      continue;
    }
    for (int i = 0; i <= 3; i++) {
      int childy = cury + dy[i];
      int childx = curx + dx[i];
      int childdir = curdir;
      int childcnt = curcnt;
      if (graph[childy][childx] != '*') {
        if (i != curdir) {
          childdir = i;
          childcnt++;
        }
        if (ans[childy][childx] >= childcnt) {
          ans[childy][childx] = childcnt;
          q.push({childy, childx, childdir, childcnt});
        }
      }
    }
  }
  cout << "NO";
}
