#include <bits/stdc++.h>
using namespace std;
bool vis[1000][1000][2][3];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<string> grid(n);
  for (auto &s : grid) cin >> s;
  function<void(int, int, bool, int)> rek = [&](int i, int j, bool d,
                                                int turns) {
    if (turns > 2) return;
    if (i < 0 || j < 0 || i >= n || j >= m) return;
    if (vis[i][j][d][turns]) return;
    if (grid[i][j] == '*') return;
    vis[i][j][d][turns] = 1;
    if (grid[i][j] == 'T') {
      puts("YES");
      exit(0);
    }
    if (d) {
      rek(i + 1, j, d, turns);
      rek(i - 1, j, d, turns);
    } else {
      rek(i, j + 1, d, turns);
      rek(i, j - 1, d, turns);
    }
    rek(i, j, !d, turns + 1);
  };
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (m); ++j)
      if (grid[i][j] == 'S') {
        rek(i, j, 0, 0);
        rek(i, j, 1, 0);
      }
  puts("NO");
}
