#include <bits/stdc++.h>
using namespace std;
int n, m;
char grid[1000][1001];
bool vis[1000][1000][3][4], arr[1000][1000][3][4];
bool dfs(int x, int y, int t, int d) {
  if (t < 3 && grid[x][y] == 'T') return 1;
  if (t > 2 || grid[x][y] == '*') return 0;
  if (x < 0 || x >= n || y < 0 || y >= m) return 0;
  if (vis[x][y][t][d]) return arr[x][y][t][d];
  vis[x][y][t][d] = 1;
  bool ret = 0;
  if (!d)
    ret = ret | dfs(x - 1, y, t, d);
  else
    ret = ret | dfs(x - 1, y, t + 1, 0);
  if (d == 1)
    ret = ret | dfs(x + 1, y, t, d);
  else
    ret = ret | dfs(x + 1, y, t + 1, 1);
  if (d == 2)
    ret = ret | dfs(x, y + 1, t, d);
  else
    ret = ret | dfs(x, y + 1, t + 1, 2);
  if (d == 3)
    ret = ret | dfs(x, y - 1, t, d);
  else
    ret = ret | dfs(x, y - 1, t + 1, 3);
  return arr[x][y][t][d] = ret;
}
int main() {
  int sx, sy;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    getchar();
    for (int j = 0; j < m; j++) {
      grid[i][j] = getchar();
      if (grid[i][j] == 'S') sx = i, sy = j;
    }
  }
  if (dfs(sx, sy, 0, 0) || dfs(sx, sy, 0, 1) || dfs(sx, sy, 0, 2) ||
      dfs(sx, sy, 0, 3))
    puts("YES");
  else
    puts("NO");
}
