#include <bits/stdc++.h>
using namespace std;
vector<string> M;
int dp[1005][1005][3][5];
int n, m;
pair<int, int> OO(int x, int y, int ori) {
  if (ori == 1) return {x - 1, y};
  if (ori == 2) return {x + 1, y};
  if (ori == 3) return {x, y - 1};
  return {x, y + 1};
}
bool ok(int x, int y) {
  if (x < 0 or y < 0 or x >= n or y >= m or M[x][y] == '*') return 0;
  return 1;
}
bool f(int x, int y, int ori, int k) {
  if (k < 0) return false;
  if (ok(x, y) == false) return false;
  if (M[x][y] == 'T') return 1;
  if (dp[x][y][k][ori] != -1) return dp[x][y][k][ori];
  dp[x][y][k][ori] = 0;
  pair<int, int> A = OO(x, y, ori);
  dp[x][y][k][ori] = f(A.first, A.second, ori, k);
  if (dp[x][y][k][ori] == 0) dp[x][y][k][ori] = f(x, y, 1, k - 1);
  if (dp[x][y][k][ori] == 0) dp[x][y][k][ori] = f(x, y, 2, k - 1);
  if (dp[x][y][k][ori] == 0) dp[x][y][k][ori] = f(x, y, 3, k - 1);
  if (dp[x][y][k][ori] == 0) dp[x][y][k][ori] = f(x, y, 4, k - 1);
  return dp[x][y][k][ori];
}
int main() {
  cin >> n >> m;
  string s;
  int a, b;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int l = 0; l < m; l++) {
      if (s[l] == 'S') {
        a = i, b = l;
      }
    }
    M.push_back(s);
  }
  memset(dp, -1, sizeof(dp));
  bool ok = 0;
  if (f(a, b, 1, 2)) ok = 1;
  if (f(a, b, 2, 2)) ok = 1;
  if (f(a, b, 3, 2)) ok = 1;
  if (f(a, b, 4, 2)) ok = 1;
  if (ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
