#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int n, m;
bool used[1010][1010][5][5];
bool border(int x, int y) { return (0 <= x and x < n) and (0 <= y and y < m); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  vector<vector<char> > a(n, vector<char>(m));
  pair<int, int> start;
  pair<int, int> finish;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'S') {
        start.first = i;
        start.second = j;
      }
      if (a[i][j] == 'T') {
        finish.first = i;
        finish.second = j;
      }
    }
  }
  queue<pair<pair<int, int>, pair<int, int> > > q;
  for (int i = 0; i < 4; i++) {
    q.push({start, {0, i}});
    used[start.first][start.second][0][i] = true;
  }
  while (!q.empty()) {
    auto v = q.front();
    q.pop();
    int dxI = v.first.first, dxJ = v.first.second;
    int turns = v.second.first, direc = v.second.second;
    for (int i = 0, nextX, nextY; i < 4; i++) {
      nextX = dxI + dx[i];
      nextY = dxJ + dy[i];
      int new_turns = turns + (i != direc);
      if (nextX != -1 and nextX != n and nextY != -1 and nextY != m and
          a[nextX][nextY] != '*' and new_turns <= 2 and
          !used[nextX][nextY][new_turns][i]) {
        q.push({{nextX, nextY}, {new_turns, i}});
        used[nextX][nextY][new_turns][i] = true;
      }
    }
  }
  for (int i = 0; i < 3; i++) {
    for (int turn = 0; turn < 4; turn++) {
      if (used[finish.first][finish.second][i][turn]) {
        cout << "YES";
        return 0;
      }
    }
  }
  cout << "NO";
  return 0;
}
