#include <bits/stdc++.h>
using namespace std;
char a[1010][1010];
int i, j, pov, n, m, sx, sy, c, e;
string s;
bool vis[1010][1010][3][4], f = false;
void dfs(int x, int y, int c, int p) {
  if (!x || !y || x > n || y > m || vis[x][y][c][p] || p > 2 || f ||
      a[x][y] == '*')
    return;
  if (a[x][y] == 'T') {
    f = 1;
    return;
  }
  vis[x][y][c][p] = 1;
  if (c)
    dfs(x + 1, y, c, p), dfs(x - 1, y, c, p);
  else
    dfs(x, y + 1, c, p), dfs(x, y - 1, c, p);
  dfs(x, y, !c, p + 1);
}
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    scanf("%s", a[i] + 1);
    for (j = 1; j <= m; j++)
      if (a[i][j] == 'S') sx = i, sy = j;
  }
  dfs(sx, sy, 0, 0), dfs(sx, sy, 1, 0);
  if (f == 1) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
