#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
char c[N][N];
bool visit[N][N][4][4];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int n, m, t = 1e9;
queue<int> Q;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> c[i][j];
      if (c[i][j] == 'S') {
        Q.push(i);
        Q.push(j);
        Q.push(-1);
        Q.push(0);
      }
    }
  }
  while (!Q.empty()) {
    int i = Q.front();
    Q.pop();
    int j = Q.front();
    Q.pop();
    int dir = Q.front();
    Q.pop();
    int tur = Q.front();
    Q.pop();
    if (tur > 2) continue;
    if (visit[i][j][dir][tur]) continue;
    visit[i][j][dir][tur] = true;
    if (c[i][j] == 'T') {
      cout << "YES\n";
      return 0;
    }
    for (int k = 0; k < 4; k++) {
      int x = i + dx[k];
      int y = j + dy[k];
      if (x >= 0 && y >= 0 && x < n && y < m && c[x][y] != '*') {
        Q.push(x);
        Q.push(y);
        Q.push(k);
        if (k == dir || dir == -1)
          Q.push(tur);
        else
          Q.push(tur + 1);
      }
    }
  }
  cout << "NO\n";
  return 0;
}
