#include <bits/stdc++.h>
using namespace std;
pair<int, int> E;
int row, col;
string grid[1010];
int ara[1010][1010][5][4];
bool flag = 0;
void road(int m, int n, int state, int con) {
  if (flag) return;
  if (!flag && m == E.first && n == E.second && con <= 3) {
    flag = 1;
    return;
  }
  if (m == row || n == col || n < 0 || m < 0 || con > 3) {
    return;
  }
  if (grid[m][n] != '*' && !ara[m][n][state][con]) {
    if (!state || state != 1)
      road(m + 1, n, 1, con + 1);
    else
      road(m + 1, n, 1, con);
    if (!state || state != 2)
      road(m, n + 1, 2, con + 1);
    else
      road(m, n + 1, 2, con);
    if (!state || state != 3)
      road(m - 1, n, 3, con + 1);
    else
      road(m - 1, n, 3, con);
    if (!state || state != 4)
      road(m, n - 1, 4, con + 1);
    else
      road(m, n - 1, 4, con);
    ara[m][n][state][con] = 1;
  }
}
int main() {
  int i, j, counts = 0;
  scanf("%d %d", &row, &col);
  pair<int, int> S;
  memset(ara, 0, sizeof(ara));
  for (i = 0; i < row; i++) {
    cin >> grid[i];
    for (int j = 0; j < grid[i].size(); j++) {
      if (grid[i][j] == 'S') {
        S = make_pair(i, j);
      }
      if (grid[i][j] == 'T') {
        E = make_pair(i, j);
      }
    }
  }
  road(S.first, S.second, 0, 0);
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
