#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
int INF = INT_MAX;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int n, m, sx, sy, ex, ey, d[N][N][4], ans = INF;
char a[N][N];
queue<pair<pair<int, int>, int> > q;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'S') sx = j, sy = i;
      if (a[i][j] == 'T') ex = j, ey = i;
      for (int k = 0; k < 4; k++) d[i][j][k] = INF;
    }
  for (int k = 0; k < 4; k++) {
    d[sy][sx][k] = 0;
    q.push({{sy, sx}, k});
  }
  while (!q.empty()) {
    int y = q.front().first.first, x = q.front().first.second,
        direction = q.front().second;
    q.pop();
    for (int k = 0; k < 4; k++) {
      if ((a[y + dy[k]][x + dx[k]] == '.' || a[y + dy[k]][x + dx[k]] == 'T') &&
          d[y + dy[k]][x + dx[k]][k] > d[y][x][direction] + (direction != k)) {
        d[y + dy[k]][x + dx[k]][k] = d[y][x][direction] + (direction != k);
        q.push({{y + dy[k], x + dx[k]}, k});
      }
    }
  }
  for (int k = 0; k < 4; k++) ans = min(ans, d[ey][ex][k]);
  if (ans <= 2)
    cout << "YES";
  else
    cout << "NO";
}
