import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

const dy = [-1, 0, 1, 0];
const dx = [0, 1, 0, -1];

void main() {
    int H, W; readf("%d %d\n", &H, &W);
    auto F = new string[H];
    foreach (ref L; F) L = readln.chomp;

    auto D = new int[][](H, W);
    foreach (ref a; D) a[] = int.max / 2;

    int sy, sx;
    void init_yx() {
        foreach (int i, L; F) {
            foreach (int j, x; L) {
                if (x == '%') {
                    sy = i;
                    sx = j;
                    return;
                }
            }
        }
        assert(false);
    }
    init_yx();

    alias P = Tuple!(int, "y", int, "x");

    D[sy][sx] = 0;
    DList!P Q;
    Q.insert(P(sy, sx));
    while (! Q.empty) {
        auto c = Q.front; Q.removeFront;
        foreach (k; 0 .. 4) {
            int ny = c.y + dy[k];
            int nx = c.x + dx[k];
            if (ny < 0 || ny >= H) continue;
            if (nx < 0 || nx >= W) continue;
            if (F[ny][nx] == '#') continue;
            if (D[ny][nx] <= D[c.y][c.x] + 1) continue;
            D[ny][nx] = D[c.y][c.x] + 1;
            Q.insert(P(ny, nx));
        }
    }

    int soldier = int.max;
    int princess = int.max;
    foreach (i, L; F) {
        foreach (j, x; L) {
            if (x == '$') {
                soldier = min(soldier, D[i][j]);
            } else if (x == '@') {
                princess = min(princess, D[i][j]);
            }
        }
    }
    writeln(princess < soldier ? "Yes" : "No");
}