// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int r, c;

int dx[]={0, 0, 1, -1};

int dy[]={1, -1, 0, 0};

char str[205][205];

int dis[205][205];

int chk[205][205];



void bfs(int i, int j){

    int a, b, tx, ty;

    queue< pair<int,int> > qu;

    pair<int, int> p;

    memset(chk, 0, sizeof chk);

    for(a=0; a<r; ++a) for(b=0; b<c; ++b) dis[a][b]=4000005;

    chk[i][j]=1;

    qu.push(make_pair(i, j));

    dis[i][j]=0;

    while(!qu.empty()){

        p=qu.front(); qu.pop();

        for(a=0; a<4; ++a){

            tx=dx[a]+p.first; ty=dy[a]+p.second;

            if(tx>=0 && tx<r && ty>=0 && ty<c && !chk[tx][ty] && str[tx][ty]!='#'){

                chk[tx][ty]=1;

                dis[tx][ty]=dis[p.first][p.second]+1;

                qu.push(make_pair(tx, ty));

            }

        }

    }

}



int main(){

    int i, j, k;

    int m1, m2=4000005;

    scanf("%d %d", &r, &c);

    for(i=0; i<r; ++i) scanf("%s", str[i]);

    for(i=0; i<r; ++i){

        for(j=0; j<c; ++j){

            if(str[i][j]=='\%'){

                bfs(i, j);

                i=r; j=c;

            }

        }

    }

    for(i=0; i<r; ++i){

        for(j=0; j<c; ++j){

            if(str[i][j]=='@') m1=dis[i][j];

            else if(str[i][j]=='$') m2=min(m2, dis[i][j]);

        }

    }



    //cout << m1 << " " << m2 << endl;



    if(m1<m2) printf("Yes\n");

    else printf("No\n");



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1680280995309922x):
#include<iostream>

#include<algorithm>

#include<cstdio>

#include<cmath>

#include <queue>



using namespace std;



const int maxx=205;

int n,m,k;

char a[maxx][maxx];

int ans = 0,cnt = 0,pos = 0;

int l = 0,r = 0;





const int INF = 100000000;

int dx[4] = {0,0,1,-1};

int dy[4] = {1,-1,0,0};

typedef pair <int,int> P;

queue<P> que;

int d[maxx][maxx];

int sx,sy;

int ex,ey;

int ans1 = INF,ans2 = INF;

bool judge(int x,int y){

    if(a[x][y] != '#'){

        if(x >= 0 && x < n)

        {

            if(y >= 0 && y < m)

            {

                if(d[x][y] == INF){

                    return true;

                }

            }

        }

    }

    return false;

}



void bfs()

{

    for(int i = 0; i < n; i++){

        for(int j = 0; j < m; j++){

            d[i][j] = INF;//初始化

        }

    }

    que.push(P(sx,sy));

    d[sx][sy] = 0;//并把距???0；

    while(que.size()){//直到?列?空

        P p = que.front();que.pop();

        if(a[p.first][p.second] == '$'){

            ans2 = min(ans2,d[p.first][p.second]);

        }

        if(a[p.first][p.second] == '@')

        {

            ans1 = min(ans1,d[p.first][p.second]);

        }

        for(int i = 0; i < 4; i++)

        {

            int nx = p.first + dx[i],ny = p.second + dy[i];

            if(judge(nx,ny))

            {

                que.push(P(nx,ny));

                d[nx][ny] = d[p.first][p.second] + 1;

            }

        }

    }

//    return d[ex][ey];

}





int main()

{

#ifdef LOCAL

//    freopen("/Users/ecooodt/Desktop/c++ and acm/_集?/tp1/2.txt","r",stdin);

#endif

    scanf("%d%d",&n,&m);

    for(int i = 0; i < n; i++)

    {

        getchar();

        for(int j = 0; j < m; j++)

        {

            scanf("%c",&a[i][j]);

            if(a[i][j] == '%')

            {

                sx = i,sy = j;

            }

        }

    }

    bfs();

    if(ans1 < ans2)

    printf("Yes\n");

    else

    printf("No\n");

    return 0;

}