#include <bits/stdc++.h>
using namespace std;
int n, m, p1, p2;
char s[1005][1005];
int kier;
bool inv[1005][1005][2][4], czy;
vector<int> v[1005][1005], u[1005][1005];
int abss(int x) {
  if (x > 0)
    return x;
  else
    return -x;
}
void dfs(int x, int y, int kier, int ilo) {
  if (ilo == 3) return;
  if (s[x][y] == 'T') {
    czy = 1;
    return;
  }
  if (kier != -1)
    inv[x][y][kier][ilo] = 1;
  else {
    inv[x][y][0][ilo] = 1;
    inv[x][y][1][ilo] = 1;
  }
  for (int i = 0; i < v[x][y].size(); i++) {
    int z = v[x][y][i];
    int z2 = u[x][y][i];
    if (abss(z - x) == kier) {
      if (!inv[z][z2][kier][ilo]) dfs(z, z2, kier, ilo);
    } else if (kier == -1)
      dfs(z, z2, abss(z - x), ilo);
    else {
      if (!inv[z][z2][abss(z - x)][ilo + 1]) dfs(z, z2, abss(z - x), ilo + 1);
    }
  }
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 1; i <= n; i++) scanf("%s", &s[i]);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'S') {
        p1 = i;
        p2 = j;
      }
      if (s[i][j] != '*') {
        if (i != n && s[i + 1][j] != '*') {
          v[i][j].push_back(i + 1);
          u[i][j].push_back(j);
          v[i + 1][j].push_back(i);
          u[i + 1][j].push_back(j);
        }
        if (j != m - 1 && s[i][j + 1] != '*') {
          v[i][j + 1].push_back(i);
          u[i][j + 1].push_back(j);
          v[i][j].push_back(i);
          u[i][j].push_back(j + 1);
        }
      }
    }
  }
  dfs(p1, p2, -1, 0);
  if (czy)
    printf("YES");
  else
    printf("NO");
  return 0;
}
