#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
const int mod = 1e9 + 9;
int Case = 1, n, m;
char ss[maxn][maxn];
int dr[4][2] = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};
int vis[maxn][maxn][5][5];
struct node {
  int x, y, d, cnt;
  node(int x = 0, int y = 0, int d = 0, int cnt = 0) {
    this->x = x;
    this->y = y;
    this->d = d;
    this->cnt = cnt;
  }
} s;
void bfs() {
  queue<node> A;
  for (int i = 0; i < 4; i++) {
    int nx = s.x + dr[i][0];
    int ny = s.y + dr[i][1];
    if (nx >= 0 && nx < n && ny >= 0 && ny < m && ss[nx][ny] != '*') {
      vis[nx][ny][i][2] = 1;
      A.push(node(nx, ny, i, 2));
    }
  }
  while (!A.empty()) {
    node temp = A.front();
    A.pop();
    if (ss[temp.x][temp.y] == 'T') {
      printf("YES\n");
      return;
    }
    for (int i = 0; i < 4; i++) {
      int nx = temp.x + dr[i][0];
      int ny = temp.y + dr[i][1];
      if (nx >= 0 && nx < n && ny >= 0 && ny < m && ss[nx][ny] != '*') {
        if (temp.d != i) {
          if (temp.cnt <= 0) continue;
          if (!vis[nx][ny][i][temp.cnt - 1]) {
            vis[nx][ny][i][temp.cnt - 1] = 1;
            A.push(node(nx, ny, i, temp.cnt - 1));
          }
        } else {
          if (!vis[nx][ny][i][temp.cnt]) {
            vis[nx][ny][i][temp.cnt] = 1;
            A.push(node(nx, ny, i, temp.cnt));
          }
        }
      }
    }
  }
  printf("NO\n");
}
void solve() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", ss[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ss[i][j] == 'S') s.x = i, s.y = j;
    }
  }
  bfs();
}
int main() {
  ios::sync_with_stdio(false);
  while (Case--) {
    solve();
  }
  return 0;
}
