// Original C++ solution (slower):
// @Team    : nupt2017team12

// @Author  : Zst

#include <iostream>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <string>

#include <vector>

#include <cmath>

#include <algorithm>

#include <map>

using namespace std;

#define LL long long

#define MOD 1000000007

#define CLR(a,x) memset(a,x,sizeof(a))

#define INF 0x3f3f3f3f

#define pb push_back

#define FOR(i,a,b) for( int i = ( a ); i <= ( b ); ++i )



const int N = 200+7;

char maps[N][N];

int vis[N][N];



int r, c;

int posX, posY;



int princess;

int soldier;



void solve( int x, int y, int times )

{

	vis[x][y] = times;

	if( maps[x][y] == '@' ) {

		princess = min( princess, times );

	} else if( maps[x][y] == '$' ) {

		soldier = min( soldier, times );

	}

	if( x-1 >= 0 ) {

		if( vis[x-1][y] == -1 ) {

			solve( x-1, y, times+1 );

		} else if( times+1 < vis[x-1][y] ) {

			solve( x-1, y, times+1 );

		}

	}

	if( y-1 >= 0 ) {

		if( vis[x][y-1] == -1 ) {

			solve( x, y-1, times+1 );

		} else if( times+1 < vis[x][y-1] ) {

			solve( x, y-1, times+1 );

		}

	}

	if( x+1 < r ) {

		if( vis[x+1][y] == -1 ) {

			solve( x+1, y, times+1 );

		} else if( times+1 < vis[x+1][y] ) {

			solve( x+1, y, times+1 );

		}

	}

	if( y+1 < c ) {

		if( vis[x][y+1] == -1 ) {

			solve( x, y+1, times+1 );

		} else if( times+1 < vis[x][y+1] ) {

			solve( x, y+1, times+1 );

		}

	}

	return;



}





int main()

{

    // freopen( "B.txt", "r", stdin );

    while( scanf( "%d%d", &r, &c ) != EOF ) {

    	princess = soldier = INF;

		CLR( vis, -1 );

	    FOR( i, 0, r-1 ) {

	    	scanf( "%s", maps[i] );

			FOR( j, 0, c-1 ) {

				if( maps[i][j] == '%' ) {

					posX = i;

					posY = j;

				} else if( maps[i][j] == '#' ) {

					vis[i][j] = true;

				}

			}

	    }

	    solve( posX, posY, 0 );

	    if( princess < soldier ) {

	    	printf( "Yes\n");

	    } else {

	    	printf( "No\n");

	    }

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem: