#include <bits/stdc++.h>
using namespace std;
const int size = 1e3 + 10;
const int INF = 1e9;
int n, m, si, sj, ti, tj;
bool a[size][size];
int used[size][size];
bool d[size][size][6][5];
void dfs(int i, int j, int k, int dir) {
  used[i][j] = min(k, used[i][j]);
  d[i][j][dir][k] = true;
  if (k == 3) return;
  if (i < n - 1 && a[i + 1][j] && (!d[i + 1][j][0][k + (dir != 0)]))
    dfs(i + 1, j, k + (dir != 0), 0);
  if (i > 0 && a[i - 1][j] && (!d[i - 1][j][1][k + (dir != 1)]))
    dfs(i - 1, j, k + (dir != 1), 1);
  if (j < m - 1 && a[i][j + 1] && (!d[i][j + 1][2][k + (dir != 2)]))
    dfs(i, j + 1, k + (dir != 2), 2);
  if (j > 0 && a[i][j - 1] && (!d[i][j - 1][3][k + (dir != 3)]))
    dfs(i, j - 1, k + (dir != 3), 3);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char c;
      cin >> c;
      used[i][j] = INF;
      a[i][j] = !(c == '*');
      if (c == 'S') {
        si = i;
        sj = j;
      }
      if (c == 'T') {
        ti = i;
        tj = j;
      }
    }
  }
  dfs(si, sj, -1, 4);
  used[ti][tj] < 3 ? cout << "YES" << '\n' : cout << "NO" << '\n';
  return 0;
}
