#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int N = 1e3 + 10;
inline int add(int x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
inline int mul(int x, int y) {
  x = (1LL * x * y) % mod;
  return x;
}
int dp[N][N][4][3];
int n, m;
string s[N];
vector<pair<int, int> > dx = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};
int dfs(int i, int j, int last, int turn) {
  if (turn == 3) return 0;
  if (s[i][j] == 'T') {
    return 1;
  }
  int &ret = dp[i][j][last][turn];
  if (~ret) return ret;
  ret = 0;
  for (int a = 0; a <= 3; ++a) {
    auto it = dx[a];
    int x = i + it.first;
    int y = j + it.second;
    if (x < 0 || y < 0 || x >= n || y >= m) continue;
    if (s[x][y] == '*') continue;
    int yy = turn;
    if (last != 0 && last != a + 1) yy++;
    int xx = dfs(x, y, a + 1, yy);
    ret |= xx;
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  pair<int, int> home = {-1, -1};
  for (int i = 0; i <= n - 1; ++i) {
    cin >> s[i];
    for (int j = 0; j <= m - 1; ++j) {
      if (s[i][j] == 'S') home = {i, j};
    }
  }
  memset(dp, -1, sizeof(dp));
  if (dfs(home.first, home.second, 0, 0) == 1) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
  return 0;
}
