#include <bits/stdc++.h>
using namespace std;
struct debugger {
  static void call(const char* it) {}
  template <typename T, typename... valT>
  static void call(const char* it, T val, valT... rest) {
    string var = "";
    for (; *it && *it != ','; it++)
      if (*it != ' ') var += *it;
    cout << var << '=' << val << ' ';
    call(++it, rest...);
  }
};
int n, m, sx, sy;
char a[1050][1050];
bool vis[1050][1050][3][4], b;
void dfs(int i, int j, int d, int t) {
  if (i < 0 || i >= n || j < 0 || j >= m) return;
  if (a[i][j] == '*' || t > 2 || vis[i][j][d][t] || b) return;
  vis[i][j][d][t] = 1;
  if (a[i][j] == 'T') {
    b = 1;
    return;
  }
  if (!d)
    dfs(i + 1, j, d, t), dfs(i - 1, j, d, t);
  else
    dfs(i, j + 1, d, t), dfs(i, j - 1, d, t);
  dfs(i, j, !d, t + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'S') {
        sx = i;
        sy = j;
      }
    }
  }
  dfs(sx, sy, 0, 0);
  dfs(sx, sy, 1, 0);
  cout << (b ? "YES" : "NO");
  return 0;
}
