#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9;
const int mod = (int)1e9 + 7;
const int N = (int)1e6 + 10;
const long long LLINF = (long long)1e18 + 10;
const double pi = acos(-1.0);
template <typename T1, typename T2>
bool umin(T1 &x, T2 y) {
  if (x > y) return x = y, true;
  return false;
}
template <typename T1, typename T2>
bool umax(T1 &x, T2 y) {
  if (x < y) return x = y, true;
  return false;
}
template <typename T>
T getint() {
  char c = getchar();
  T p = 1, x = 0;
  while (c == ' ' || c == '\n') c = getchar();
  if (c == '-') p = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * p;
}
char a[1003][1003];
int n, m;
bool used[1003][1003][5][4];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
void dfs(int x, int y, int to, int num) {
  if (a[x][y] == '*' || x < 0 || y < 0 || x >= n || y >= m) return;
  used[x][y][to][num] = true;
  if (!used[x + dx[to]][y + dy[to]][to][num])
    dfs(x + dx[to], y + dy[to], to, num);
  if (num == 2) return;
  for (int i = 0; i < 4; ++i) {
    if (i == to) continue;
    if (!used[x + dx[i]][y + dy[i]][i][num + 1])
      dfs(x + dx[i], y + dy[i], i, num + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  int xs, ys, xf, yf;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
      if (a[i][j] == 'S') xs = i, ys = j;
      if (a[i][j] == 'T') xf = i, yf = j;
    }
  }
  for (int i = 0; i < 4; ++i) dfs(xs, ys, i, 0);
  string ans = "NO";
  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (used[xf][yf][i][j]) ans = "YES";
    }
  }
  cout << ans;
  return 0;
}
