#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T POW(T B, T P) {
  if (P == 0) return 1;
  if (P & 1)
    return B * POW(B, P - 1);
  else
    return (POW(B, P / 2) * POW(B, P / 2));
}
template <typename T>
inline T Gcd(T a, T b) {
  if (a < 0) return Gcd(-a, b);
  if (b < 0) return Gcd(a, -b);
  return (b == 0) ? a : Gcd(b, a % b);
}
template <typename T>
inline T Lcm(T a, T b) {
  if (a < 0) return Lcm(-a, b);
  if (b < 0) return Lcm(a, -b);
  return a * (b / Gcd(a, b));
}
long long Bigmod(long long base, long long power, long long MOD) {
  long long ret = 1;
  while (power) {
    if (power & 1) ret = (ret * base) % MOD;
    base = (base * base) % MOD;
    power >>= 1;
  }
  return ret;
}
bool isVowel(char ch) {
  ch = toupper(ch);
  if (ch == 'A' || ch == 'U' || ch == 'I' || ch == 'O' || ch == 'E')
    return true;
  return false;
}
long long ModInverse(long long number, long long MOD) {
  return Bigmod(number, MOD - 2, MOD);
}
bool isConst(char ch) {
  if (isalpha(ch) && !isVowel(ch)) return true;
  return false;
}
int toInt(string s) {
  int sm;
  stringstream second(s);
  second >> sm;
  return sm;
}
char a[1002][1002];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
bool ok[1002][1002][5][5];
int main() {
  int n, m;
  cin >> n >> m;
  queue<int> q;
  int X, Y;
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < m + 1; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'S') {
        q.push(i);
        q.push(j);
        q.push(0);
        q.push(6);
      } else if (a[i][j] == 'T') {
        X = i, Y = j;
      }
    }
  }
  int ans = 1e9;
  while (q.size()) {
    int x = q.front();
    q.pop();
    int y = q.front();
    q.pop();
    int tm = q.front();
    q.pop();
    int dr = q.front();
    q.pop();
    if (x == X && y == Y) {
      ans = min(ans, tm);
    }
    for (int i = 0; i < 4; i++) {
      int xx = x + dx[i];
      int yy = y + dy[i];
      if (xx <= 0 || xx > n || yy <= 0 || yy > m || a[xx][yy] == '*') continue;
      int nt = tm;
      if (dr != 6 && abs(dr - i)) nt = nt + 1;
      if (nt <= 2 && !ok[xx][yy][nt][i]) {
        q.push(xx);
        q.push(yy);
        q.push(nt);
        q.push(i);
        ok[xx][yy][nt][i] = 1;
      }
    }
  }
  cerr << "ans"
       << ": " << ans << endl;
  if (ans <= 2) {
    printf("YES\n");
  } else
    cout << "NO\n";
  return 0;
}
