#include <bits/stdc++.h>
using namespace std;
const int N = 1003;
int m, n, xs, ys, xt, yt;
char s[N][N];
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
bool mark[N][N][4][3];
void dfs(int x, int y, int d, int c) {
  mark[x][y][d][c] = 1;
  if (x == xt && y == yt) {
    puts("YES");
    exit(0);
  }
  for (int i = 0; i < 4; ++i) {
    int xx = x + dx[i], yy = y + dy[i];
    if (xx < 0 || xx >= m || yy < 0 || yy >= n || s[xx][yy] == '*') continue;
    if (d == i && !mark[xx][yy][i][c])
      dfs(xx, yy, i, c);
    else if (c < 2 && !mark[xx][yy][i][c + 1])
      dfs(xx, yy, i, c + 1);
  }
}
int main() {
  scanf("%d%d", &m, &n);
  for (int i = 0; i < m; ++i) {
    scanf("%s", s[i]);
    for (int j = 0; j < n; ++j) {
      if (s[i][j] == 'S')
        xs = i, ys = j;
      else if (s[i][j] == 'T')
        xt = i, yt = j;
    }
  }
  for (int i = 0; i < 4; ++i) dfs(xs, ys, i, 0);
  puts("NO");
}
