#include <bits/stdc++.h>
using namespace std;
char s[1010][1010];
int vis[1010][1010][5];
int d[4][2] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
bool flag = false;
int n, m;
void DFS(int x, int y, int dir, int turn) {
  if (x < 1 || x > n || y < 1 || y > m || turn > 2) return;
  if (vis[x][y][dir] <= turn) return;
  if (s[x][y] == 'T') {
    flag = true;
    return;
  }
  if (s[x][y] == '*') return;
  vis[x][y][dir] = turn;
  for (int i = 0; i < 4; i++) {
    int x1 = x + d[i][0];
    int y1 = y + d[i][1];
    if (dir == -1) {
      DFS(x1, y1, i, turn);
    } else if (dir != i) {
      DFS(x1, y1, i, turn + 1);
    } else {
      DFS(x1, y1, i, turn);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
  }
  int sx, sy;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (s[i][j] == 'S') {
        sx = i;
        sy = j;
        break;
      }
    }
  }
  memset(vis, 0x3f, sizeof(vis));
  DFS(sx, sy, -1, 0);
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
