#include <bits/stdc++.h>
using namespace std;
const long long N = 1e3 + 5;
long long f1[N][N], f2[N][N], n, m;
pair<long long, long long> ini, fim;
char c[N][N];
void arruma(pair<long long, long long> pa, long long f[N][N]) {
  long long x = pa.first, y = pa.second;
  for (long long i = x; i < n; ++i) {
    if (c[i][y] == '*') break;
    f[i][y] = 1;
  }
  for (long long i = x; i >= 0; --i) {
    if (c[i][y] == '*') break;
    f[i][y] = 1;
  }
  for (long long i = y; i < m; ++i) {
    if (c[x][i] == '*') break;
    f[x][i] = 1;
  }
  for (long long i = y; i >= 0; --i) {
    if (c[x][i] == '*') break;
    f[x][i] = 1;
  }
}
bool check(long long x, long long y) {
  for (long long i = x; i < n; ++i) {
    if (c[i][y] == '*') break;
    if (f2[i][y]) {
      return true;
    }
  }
  for (long long i = x; i >= 0; --i) {
    if (c[i][y] == '*') break;
    if (f2[i][y]) {
      return true;
    }
  }
  for (long long i = y; i < m; ++i) {
    if (c[x][i] == '*') break;
    if (f2[x][i]) {
      return true;
    }
  }
  for (long long i = y; i >= 0; --i) {
    if (c[x][i] == '*') break;
    if (f2[x][i]) {
      return true;
    }
  }
  return false;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < (n); ++i) {
    for (long long j = 0; j < (m); ++j) {
      cin >> c[i][j];
      char agr = c[i][j];
      if (agr == 'S') {
        ini = pair<long long, long long>(i, j);
      }
      if (agr == 'T') {
        fim = pair<long long, long long>(i, j);
      }
    }
  }
  arruma(ini, f1);
  arruma(fim, f2);
  for (long long i = 0; i < (n); ++i) {
    for (long long j = 0; j < (m); ++j) {
      if (f1[i][j]) {
        if (check(i, j)) {
          cout << "YES\n";
          return 0;
        }
      }
    }
  }
  cout << "NO\n";
}
