#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > M;
int n, m;
queue<pair<int, int> > q;
int recorrer(int x, int y) {
  int x1, y1;
  int cont = 0;
  for (int i = -1; i < 2; i++) {
    for (int j = -1; j < 2; j++) {
      x1 = x;
      y1 = y;
      if (abs(i) == abs(j)) continue;
      while (true) {
        x1 += i;
        y1 += j;
        if (x1 < 0 || n <= x1 || y1 < 0 || m <= y1) break;
        if (M[x1][y1] == 2) break;
        if (M[x1][y1] == 0) {
          cont++;
          q.push(pair<int, int>(x1, y1));
        }
        M[x1][y1] = 1;
      }
    }
  }
  return cont;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  pair<int, int> s, t;
  M.assign(n, vector<int>(m, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char c;
      cin >> c;
      if (c == '.' || c == 'S' || c == 'T') M[i][j] == 0;
      if (c == 'S') s = pair<int, int>(i, j);
      if (c == 'T') t = pair<int, int>(i, j);
      if (c == '*') M[i][j] = 2;
    }
  }
  M[s.first][s.second] = 1;
  int cont = recorrer(s.first, s.second);
  int contn = 0;
  while (cont != 0) {
    pair<int, int> p = q.front();
    q.pop();
    contn += recorrer(p.first, p.second);
    cont--;
  }
  int ver = 0;
  int x1, y1;
  for (int i = -1; i < 2; i++) {
    for (int j = -1; j < 2; j++) {
      x1 = t.first;
      y1 = t.second;
      if (abs(i) == abs(j)) continue;
      while (true) {
        x1 += i;
        y1 += j;
        if (x1 < 0 || n <= x1 || y1 < 0 || m <= y1) break;
        if (M[x1][y1] == 2) break;
        if (M[x1][y1] == 1) ver = 1;
        M[x1][y1] = 3;
      }
    }
  }
  if (ver)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
