#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > grid;
int n, m;
int oX, oY, fX, fY;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dp[1001][1001][4][3];
bool doable(int x, int y) {
  return (!(x < 0 || x >= n || y < 0 || y >= m || grid[x][y] == 1));
}
void turnCount(int x, int y, int d, int c) {
  if (!doable(x, y) || c > 2 || dp[x][y][d][c]) return;
  if (grid[x][y] == 3) {
    printf("YES\n");
    exit(0);
  }
  dp[x][y][d][c] = 1;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    i == d ? turnCount(nx, ny, d, c) : turnCount(nx, ny, i, c + 1);
  }
}
int main() {
  int i, j;
  char input[2000];
  int skip;
  char c;
  char *data;
  scanf("%d %d", &n, &m);
  scanf("\n");
  for (i = 0; i < n; i++) {
    fgets(input, 2000, stdin);
    data = input;
    vector<int> vec;
    for (j = 0; j < m; j++) {
      sscanf(data, "%c%n", &c, &skip);
      data += skip;
      switch (c) {
        case '.':
          vec.push_back(0);
          break;
        case '*':
          vec.push_back(1);
          break;
        case 'S':
          oX = i;
          oY = j;
          vec.push_back(2);
          break;
        case 'T':
          fX = i;
          fY = j;
          vec.push_back(3);
          break;
      }
    }
    grid.push_back(vec);
  }
  for (i = 0; i < 4; i++) {
    memset(dp, 0, sizeof(dp));
    turnCount(oX, oY, i, 0);
  }
  printf("NO\n");
  return 0;
}
