#include <bits/stdc++.h>
using namespace std;
long long n, m;
char a[1001][1001];
bool vis[1001][1001][4][3];
long long dx[] = {0, 1, 0, -1};
long long dy[] = {1, 0, -1, 0};
bool dfs(long long x, long long y, long long d, long long turn) {
  long long i = x, j = y;
  if (i == n || j == m || i < 0 || j < 0 || turn > 2 || vis[i][j][d][turn] ||
      a[i][j] == '*')
    return 0;
  if (a[i][j] == 'T') return 1;
  vis[x][y][d][turn] = 1;
  bool ans = 0;
  for (long long k = 0; k < 4; k++) {
    ans = ans ||
          (dfs(x + dx[k], y + dy[k], k, turn + ((k == d || d == -1) ? 0 : 1)));
  }
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n >> m;
  long long x, y;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'S') x = i, y = j;
    }
  }
  bool ans = dfs(x, y, -1, 0);
  if (ans)
    cout << "YES";
  else
    cout << "NO";
}
