#include <bits/stdc++.h>
using namespace std;
string s[1002];
long long dp[1002][1002][4][3];
long long dx[] = {1, 0, -1, 0};
long long dy[] = {0, 1, 0, -1};
long long r3, r4;
map<char, bool> gd;
long long n, m;
long long vis[1002][1002];
long long dfs(long long i, long long j, long long mvs, long long lst,
              long long r1, long long r2) {
  if (mvs < 0) return 0;
  vis[i][j] = mvs;
  if (i == r3 && j == r4) return 1;
  if (dp[i][j][mvs][lst] == -1) {
    long long tmp = 0;
    for (long long k = 0; k < 4; k++) {
      long long ii = i + dx[k];
      long long jj = j + dy[k];
      if (ii == n || jj == m || ii < 0 || jj < 0) continue;
      if (gd[s[ii][jj]]) {
        long long f = 0;
        if (dx[k] != 0)
          f = (lst == 2);
        else
          f = (lst == 1);
        if (vis[ii][jj] > mvs - f || (ii == r1 && jj == r2)) continue;
        tmp = max(tmp, dfs(ii, jj, mvs - f, 2 - (dx[k] != 0), i, j));
      }
    }
    dp[i][j][mvs][lst] = tmp;
  }
  return dp[i][j][mvs][lst];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  memset(vis, -1, sizeof vis);
  memset(dp, -1, sizeof dp);
  for (long long i = 0; i < n; i++) cin >> s[i];
  long long r1, r2;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (s[i][j] == 'S') {
        r1 = i;
        r2 = j;
      }
      if (s[i][j] == 'T') {
        r3 = i;
        r4 = j;
      }
    }
  }
  gd['.'] = 1;
  gd['T'] = 1;
  gd['S'] = 1;
  long long res = dfs(r1, r2, 2, 0, -1, -1);
  cout << (res ? "YES" : "NO");
  return 0;
}
