#include <bits/stdc++.h>
using namespace std;
int n, m, xi, yi;
string city[1000];
bool visit[1000][1000][3][4];
int dirX[4] = {-1, +1, 0, 0};
int dirY[4] = {0, 0, -1, +1};
bool valid(int x, int y, int moves) {
  return x > -1 && x < n && y > -1 && y < m && city[x][y] != '*';
}
bool solve(int x, int y, int moves, int dir) {
  if (moves > 2) return false;
  if (!valid(x, y, moves)) return false;
  if (city[x][y] == 'T') return true;
  if (visit[x][y][moves][dir - 1]) return false;
  visit[x][y][moves][dir - 1] = true;
  for (int i = 1; i <= 4; i++)
    if (solve(x + dirX[i - 1], y + dirY[i - 1], moves + (i != dir), i))
      return true;
  return false;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> city[i];
    for (int j = 0; j < m; j++)
      if (city[i][j] == 'S') xi = i, yi = j;
  }
  for (int i = 1; i <= 4; i++)
    if (solve(xi, yi, 0, i)) {
      cout << "YES\n";
      return 0;
    }
  cout << "NO\n";
  return 0;
}
