#include <bits/stdc++.h>
using namespace std;
struct Amocana_A {
  void solve() {
    long long n, k;
    cin >> n >> k;
    vector<long long> v(n);
    for (int i = int(0); i < int(n); i++) cin >> v[i];
    sort((v).begin(), (v).end());
    for (int i = int(n - 1); i >= int(0); i--) v[i] -= v[0];
    long long ans = 0;
    for (int i = int(1); i < int(n); i++) {
      if (v[i] % k == 0)
        ans += v[i] / k;
      else {
        cout << -1 << endl;
        return;
      }
    }
    cout << ans << endl;
  }
};
struct Amocana_B {
  int n, m;
  pair<int, int> s, e;
  void solve() {
    cin >> n >> m;
    vector<string> g(n);
    for (int i = int(0); i < int(n); i++) {
      cin >> g[i];
      for (int j = int(0); j < int(m); j++) {
        if (g[i][j] == 'S') s = pair<int, int>(i, j);
        if (g[i][j] == 'T') e = pair<int, int>(i, j);
      }
    }
    vector<pair<int, int> > mim = {pair<int, int>(1, 0), pair<int, int>(0, 1),
                                   pair<int, int>(-1, 0),
                                   pair<int, int>(0, -1)};
    for (int i = int(0); i < int(4); i++) {
      pair<int, int> ss = s;
      while (true) {
        ss.first += mim[i].first;
        ss.second += mim[i].second;
        if (ss.first >= n || ss.first < 0 || ss.second >= m || ss.second < 0)
          break;
        if (g[ss.first][ss.second] == '.')
          g[ss.first][ss.second] = 'S';
        else if (g[ss.first][ss.second] == 'T') {
          cout << "YES\n";
          return;
        } else if (g[ss.first][ss.second] == '*')
          break;
      }
      ss = e;
      while (true) {
        ss.first += mim[i].first;
        ss.second += mim[i].second;
        if (ss.first >= n || ss.first < 0 || ss.second >= m || ss.second < 0)
          break;
        if (g[ss.first][ss.second] == '.')
          g[ss.first][ss.second] = 'T';
        else if (g[ss.first][ss.second] == 'S') {
          cout << "YES\n";
          return;
        } else if (g[ss.first][ss.second] == '*')
          break;
      }
    }
    for (int a = int(0); a < int(n); a++) {
      for (int b = int(0); b < int(m); b++) {
        if (g[a][b] == 'S') {
          for (int i = int(0); i < int(4); i++) {
            pair<int, int> ss = pair<int, int>(a, b);
            while (true) {
              ss.first += mim[i].first;
              ss.second += mim[i].second;
              if (ss.first >= n || ss.first < 0 || ss.second >= m ||
                  ss.second < 0)
                break;
              if (g[ss.first][ss.second] == 'T') {
                cout << "YES\n";
                return;
              } else if (g[ss.first][ss.second] == '*')
                break;
            }
          }
        }
      }
    }
    cout << "NO\n";
  }
};
struct Amocana_C {
  void solve() {}
};
struct Amocana_D {
  void solve() {}
};
struct Amocana_E {
  void solve() {}
};
struct Amocana_F {
  void solve() {}
};
struct Amocana_G {
  void solve() {}
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  Amocana_B solver;
  solver.solve();
  return 0;
}
