#include <bits/stdc++.h>
char mp[1010][1010];
int vis[1010][1010][3][5];
int n, m, ans;
int x, y;
void location() {
  int i, j;
  memset(vis, 0, sizeof(vis));
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (mp[i][j] == 'S') {
        x = i;
        y = j;
      }
    }
  }
}
void dfs(int x, int y, int turn, int d) {
  if (x < 0 || x >= n || y < 0 || y >= m || turn > 2 ||
      vis[x][y][turn][d] == 1 || mp[x][y] == '*' || ans == 1)
    return;
  vis[x][y][turn][d] = 1;
  if (mp[x][y] == 'T') {
    ans = 1;
    return;
  }
  if (d == 0 || d == 1)
    dfs(x - 1, y, turn, 1);
  else if (d == 3 || d == 4)
    dfs(x - 1, y, turn + 1, 1);
  if (d == 0 || d == 2)
    dfs(x + 1, y, turn, 2);
  else if (d == 3 || d == 4)
    dfs(x + 1, y, turn + 1, 2);
  if (d == 0 || d == 3)
    dfs(x, y - 1, turn, 3);
  else if (d == 1 || d == 2)
    dfs(x, y - 1, turn + 1, 3);
  if (d == 0 || d == 4)
    dfs(x, y + 1, turn, 4);
  else if (d == 1 || d == 2)
    dfs(x, y + 1, turn + 1, 4);
}
int main() {
  int i;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (i = 0; i < n; i++) scanf("%s", mp[i]);
    location();
    ans = 0;
    dfs(x, y, 0, 0);
    if (ans)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
