#define _CRT_SECURE_NO_WARNINGS
#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <hash_map>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
using namespace std;

#define PI 3.14159265359
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfstr(v) scanf("%s", v);
#define sz(v) v.size()
#define ndl puts("")
#define SS stringstream
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int n, m;
char a[1005][1005];
bool vis[1005][1005];


bool valid(int i, int j) { return i >= 0 && i < n && j >= 0 && j < m; }
int main() {
	PLAY();

	cin >> n >> m;
	pair<int, int> start, end;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
			if (a[i][j] == 'S') start = { i, j };
			else if (a[i][j] == 'T') end = { i, j };
		}
	}

	queue<pair<pair<int, int>, pair<int,int>>> qu;
	qu.push({ start, { -1, 0 } });
	while (sz(qu)) {
		int x = qu.front().first.first;
		int y = qu.front().first.second;
		int lastmove = qu.front().second.first;
		int cnt = qu.front().second.second;
		qu.pop();
		if (make_pair(x, y) == end) {
			cout << "YES" << endl;
			return 0;
		}
		if (vis[x][y]) continue;
		vis[x][y] = true;
		for (int i = 0; i < 4; i++) {
			int tox = dx[i] + x;
			int toy = dy[i] + y;
			if (!valid(tox, toy)) continue;
			if (a[tox][toy] == '*') continue;
			if (lastmove == -1) {
				if (!vis[tox][toy])
					qu.push({ { tox, toy }, { i, 0 } });
			}
			else {
				int newcnt = cnt + bool(lastmove != i);
				if (newcnt > 2) continue;
				if (!vis[tox][toy])
					qu.push({ { tox, toy }, { i, newcnt } });
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}