#include <bits/stdc++.h>
using namespace std;
char a[1003][1003];
int n, m;
int d[1003][1003][4];
int dr[4] = {0, -1, 0, 1};
int dc[4] = {1, 0, -1, 0};
queue<pair<int, int> > Q;
int sr, sc, tx, ty;
void BFS() {
  for (int i = 0; i < 4; i++) {
    Q.push(pair<int, int>(sr, sc * 4 + i));
  }
  for (int i = 0; i < 4; i++) {
    d[sr][sc][i] = 0;
  }
  while (!Q.empty()) {
    int ar = Q.front().first;
    int ac = Q.front().second / 4;
    int ad = Q.front().second % 4;
    Q.pop();
    for (int i = 0; i < 4; ++i) {
      if (i != ad && d[ar][ac][i] == -1) {
        d[ar][ac][i] = d[ar][ac][ad] + 1;
        Q.push(pair<int, int>(ar, ac * 4 + i));
      }
    }
    int nr = ar + dr[ad], nc = ac + dc[ad];
    if (nr < 0 || n <= nr || nc < 0 || m <= nc) continue;
    if (a[nr][nc] != '*' && d[nr][nc][ad] == -1) {
      d[nr][nc][ad] = d[ar][ac][ad];
      Q.push(pair<int, int>(nr, nc * 4 + ad));
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", &a[i]);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      for (int k = 0; k < 4; k++) {
        d[i][j][k] = -1;
      }
      if (a[i][j] == 'S') {
        sr = i;
        sc = j;
      } else if (a[i][j] == 'T') {
        tx = i;
        ty = j;
      }
    }
  }
  BFS();
  for (int i = 0; i < 4; i++) {
    if (d[tx][ty][i] >= 0 && d[tx][ty][i] <= 2) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
