#include <bits/stdc++.h>
using namespace std;
long long int a[1000009], arr[1008][1008][4][3], p[1000009];
long long int n, m, q;
char v[1007][1007];
bool check(int a, int b) {
  if (a >= 0 && a < n && b >= 0 && b < m && v[a][b] != '*')
    return true;
  else
    return false;
}
void solve(int i, int j, int c, int s) {
  if (c > 2) return;
  if (q == 1 || arr[i][j][s][c] == 1) {
    return;
  }
  if (!check(i, j)) return;
  if (v[i][j] == 'T') {
    q = 1;
    return;
  }
  if (s == 0) {
    solve(i + 1, j, c, s);
    solve(i - 1, j, c + 1, 1);
    solve(i, j - 1, c + 1, 2);
    solve(i, j + 1, c + 1, 3);
  } else if (s == 1) {
    solve(i - 1, j, c, s);
    solve(i + 1, j, c + 1, 0);
    solve(i, j - 1, c + 1, 2);
    solve(i, j + 1, c + 1, 3);
  } else if (s == 2) {
    solve(i, j - 1, c, s);
    solve(i + 1, j, c + 1, 0);
    solve(i - 1, j, c + 1, 1);
    solve(i, j + 1, c + 1, 3);
  } else if (s == 3) {
    solve(i, j + 1, c, s);
    solve(i + 1, j, c + 1, 0);
    solve(i - 1, j, c + 1, 1);
    solve(i, j - 1, c + 1, 2);
  }
  arr[i][j][s][c] = 1;
}
int main() {
  long long int k = 0, x = 0, y = 0, f = 0, res = -100000000000, d = 0, c = 0,
                t = 0;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf(" %c", &v[i][j]);
      if (v[i][j] == 'S') {
        x = i;
        y = j;
      }
    }
  }
  solve(x, y, 0, 0);
  solve(x, y, 0, 1);
  solve(x, y, 0, 2);
  solve(x, y, 0, 3);
  if (q == 1)
    cout << "YES";
  else
    cout << "NO";
}
