#include <bits/stdc++.h>
using namespace std;
char b[1000][1001];
int n, m;
bool d[4][3][1000][1001];
int dr[4] = {-1, 0, 1, 0};
int dc[4] = {0, 1, 0, -1};
bool pos(int r, int c) {
  return 0 <= r && r < n && 0 <= c && c < m && b[r][c] != '*';
}
int main() {
  scanf("%d %d", &n, &m);
  queue<tuple<int, int, int, int> > q;
  int tr, tc;
  for (int i = 0; i < n; i++) {
    scanf("%s", b[i]);
    for (int j = 0; j < m; j++) {
      if (b[i][j] == 'S') {
        for (int k = 0; k < 4; k++) {
          q.push(tuple<int, int, int, int>(k, 0, i, j));
          d[k][0][i][j] = true;
        }
      } else if (b[i][j] == 'T') {
        tr = i;
        tc = j;
      }
    }
  }
  tuple<int, int, int, int> t;
  bool ok = false;
  while (!q.empty() && !ok) {
    t = q.front();
    q.pop();
    int dir = get<0>(t), num = get<1>(t), cr = get<2>(t), cc = get<3>(t);
    for (int i = 0; i < 4; i++) {
      int add = (i != dir);
      if (num + add > 2) continue;
      int nr = cr + dr[i], nc = cc + dc[i];
      if (!pos(nr, nc)) continue;
      if (!d[i][num + add][nr][nc]) {
        d[i][num + add][nr][nc] = true;
        q.push(tuple<int, int, int, int>(i, num + add, nr, nc));
        if (nr == tr && nc == tc) ok = true;
      }
    }
  }
  puts(ok ? "YES" : "NO");
  return 0;
}
