#include <bits/stdc++.h>
using namespace std;
long long pow(int a, int b, long long MOD) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y);
      if (x > MOD) x %= MOD;
    }
    y = (y * y);
    if (y > MOD) y %= MOD;
    b /= 2;
  }
  return x;
}
long long InverseEuler(int n, long long MOD) { return pow(n, MOD - 2, MOD); }
int hcf(int n1, int n2) {
  if (n2 != 0)
    return hcf(n2, n1 % n2);
  else
    return n1;
}
int p[2000000] = {}, c[100000];
void prime() {
  int k = 0;
  for (int i = 2; i <= 200000; i++) {
    if (p[i] == 0) {
      c[k++] = i;
      if (k > 100000) return;
      for (int j = 2 * i; j <= 200000; j += i) p[j] = 1;
    }
  }
  p[0] = 1;
  p[1] = 1;
}
int n, m, x, y;
string a[1003];
int vis[1002][1002];
int chk(int i, int j) {
  if (i >= 0 && i < n && j >= 0 && j < m) return 1;
  return 0;
}
int f = 0;
int xx[] = {0, 1, 0, -1};
int yy[] = {1, 0, -1, 0};
int dd[1002][1002][4][3] = {};
int sol(int ii, int jj, int c, int d) {
  if (chk(ii, jj) == 0 || c > 2 || dd[ii][jj][d][c] || a[ii][jj] == '*')
    return false;
  if (a[ii][jj] == 'T') return true;
  dd[ii][jj][d][c] = 1;
  int res = 0;
  for (int k = 0; k < 4; k++)
    res |= sol(ii + xx[k], jj + yy[k], c + ((k != d) ? 1 : 0), k);
  return res;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  int c1, c2;
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 'S') {
        c1 = i, c2 = j;
        break;
      }
    }
  }
  int s = 0;
  s = sol(c1, c2, 0, 0) || sol(c1, c2, 0, 1) || sol(c1, c2, 0, 2) ||
      sol(c1, c2, 0, 3);
  if (s)
    cout << "YES";
  else
    cout << "NO";
}
