import scala.collection.mutable
object Main extends App {
  import scala.io.StdIn._
  val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
  val state = Array.tabulate(h){_ ⇒ readLine.trim.toCharArray}
  val hatch = (0 until w).flatMap(x ⇒ (0 until h).filter(y ⇒ state(y)(x) == '%').map(y ⇒ Coordinate(x, y))).head
  val princess = (0 until w).flatMap(x ⇒ (0 until h).filter(y ⇒ state(y)(x) == '@').map(y ⇒ Coordinate(x, y))).head
  val minCost = Array.tabulate(h){_ ⇒ Array.tabulate(w){_ ⇒ -1}}
  minCost(hatch.y)(hatch.x) == 0
  val queue = mutable.Queue[Coordinate](hatch)

  while(queue.nonEmpty){
    val top = queue.dequeue()
    for (next ← top.neighbors if (0 until w).contains(next.x) && (0 until h).contains(next.y) && minCost(next.y)(next.x) == -1 && state(next.y)(next.x) != '#'){
      minCost(next.y)(next.x) = minCost(top.y)(top.x) + 1
      queue.enqueue(next)
    }
  }

  println(
    if ((0 until w).exists(x ⇒ (0 until h).exists(y ⇒ state(y)(x) == '$' && minCost(y)(x) <= minCost(princess.y)(princess.x)))) "No" else "Yes"
  )

  case class Coordinate(x: Int, y: Int) {
    def neighbors: List[Coordinate] = List(Coordinate(x + 1, y), Coordinate(x - 1, y), Coordinate(x, y + 1), Coordinate(x, y - 1))
  }
}
