fun main(args: Array<String>) {
    val s = readLine()!!
    val (x, y) = readLine()!!.split(" ").map(String::toInt)
    val ds = s.split("T").map { it.length }
    val dxs = ds.withIndex().filter { it.index % 2 == 0 }.map { it.value }
    val dys = ds.withIndex().filter { it.index % 2 == 1 }.map { it.value }
    val xSet = calculateSet(dxs[0], dxs.slice(1 until dxs.size))
    val ySet = calculateSet(0, dys)
    println(if (x in xSet && y in ySet) "Yes" else "No")
}

fun calculateSet(init: Int, ds: List<Int>): Set<Int> {
    return ds.fold(setOf(init), { current_set, d ->
        current_set.toList().map { listOf(it - d, it + d) }.flatten().toSet()
    })
}