#include <bits/stdc++.h>
using namespace std;
int n, m;
char a[1005][1005];
bool vis[1005][1005][3][5];
bool ans;
void dfs(int r, int c, int k, int d) {
  if (r < 0 || r > n - 1 || c < 0 || c > m - 1 || a[r][c] == '*' || k > 2)
    return;
  if (a[r][c] == 'T') {
    ans = true;
    return;
  }
  if (d == 0 || d == 1) {
    if (vis[r][c][k][0] || vis[r][c][k][1]) return;
  }
  if (d == 2 || d == 3) {
    if (vis[r][c][k][2] || vis[r][c][k][3]) return;
  }
  vis[r][c][k][d] = true;
  if (d == 0) {
    dfs(r, c - 1, k, 0), dfs(r, c + 1, k, 1), dfs(r - 1, c, k + 1, 2),
        dfs(r + 1, c, k + 1, 3);
  }
  if (d == 1) {
    dfs(r, c - 1, k, 0), dfs(r, c + 1, k, 1), dfs(r - 1, c, k + 1, 2),
        dfs(r + 1, c, k + 1, 3);
  }
  if (d == 2) {
    dfs(r, c - 1, k + 1, 0), dfs(r, c + 1, k + 1, 1), dfs(r - 1, c, k, 2),
        dfs(r + 1, c, k, 3);
  }
  if (d == 3) {
    dfs(r, c - 1, k + 1, 0), dfs(r, c + 1, k + 1, 1), dfs(r - 1, c, k, 2),
        dfs(r + 1, c, k, 3);
  }
}
int main() {
  int i, j;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (a[i][j] == 'S') {
        dfs(i, j - 1, 0, 0), dfs(i, j + 1, 0, 1), dfs(i - 1, j, 0, 2),
            dfs(i + 1, j, 0, 3);
        break;
      }
    }
  }
  if (ans)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
