#include <bits/stdc++.h>
using namespace std;
int n, m;
char vis[1005][1005];
int x, y, x2, y2;
class A {
 public:
  int x, y, t;
};
int pd(int x, int y) {
  if (x >= 1 && x <= n && y >= 1 && y <= m &&
      (vis[x][y] == '.' || vis[x][y] == 'T' ||
       (vis[x][y] >= '1' && vis[x][y] <= '4')))
    return 1;
  return 0;
}
A a, p;
queue<A> que;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> vis[i][j];
      if (vis[i][j] == 'S') a.x = i, a.y = j, a.t = 0;
      if (vis[i][j] == 'T') x2 = i, y2 = j;
    }
  que.push(a);
  for (int i = 0; i < 3; i++) {
    while (que.size() != 0 && i == (que.front()).t) {
      a = que.front();
      que.pop();
      a.t++;
      int x = a.x, y = a.y;
      a.x++;
      while (pd(a.x, a.y)) {
        if (a.x == x2 && a.y == y2) {
          cout << "YES";
          return 0;
        }
        if (vis[a.x][a.y] != '1') {
          vis[a.x][a.y] = '1';
          que.push(a);
        } else
          break;
        a.x++;
      }
      a.x--;
      a.x = x - 1;
      while (pd(a.x, a.y)) {
        if (a.x == x2 && a.y == y2) {
          cout << "YES";
          return 0;
        }
        if (vis[a.x][a.y] != '2') {
          vis[a.x][a.y] = '2';
          que.push(a);
        } else
          break;
        a.x--;
      }
      a.x++;
      a.x = x;
      a.y = y - 1;
      while (pd(a.x, a.y)) {
        if (a.x == x2 && a.y == y2) {
          cout << "YES";
          return 0;
        }
        if (vis[a.x][a.y] != '3') {
          vis[a.x][a.y] = '3';
          que.push(a);
        } else
          break;
        a.y--;
      }
      a.y++;
      a.x = x;
      a.y = y + 1;
      while (pd(a.x, a.y)) {
        if (a.x == x2 && a.y == y2) {
          cout << "YES";
          return 0;
        }
        if (vis[a.x][a.y] != '4') {
          vis[a.x][a.y] = '4';
          que.push(a);
        } else
          break;
        a.y++;
      }
      a.y--;
    }
  }
  cout << "NO" << endl;
  return 0;
}
