// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

//file stream

#define output freopen("output.txt","w",stdout)

#define input freopen("input.txt","r",stdin)

//functions

#define pb(x)  push_back(x)

// if needed pair

#define f first

#define s second

#define mp(x,y) make_pair(x,y)





//inputs 1 var

#define s1i(n) scanf("%d",&n)

#define s1u(n) scanf("%u",&n)

#define s1l(n) scanf("%lld",&n)

#define s1lu(n) scanf("%llu",&n)

#define s1d(n) scanf("%lf",&n)

#define s1s(n) scanf("%s",n)

//inputs 2 var

#define s2i(n,m) scanf("%d %d",&n,&m)

#define s2u(n,m) scanf("%u %u",&n,&m)

#define s2l(n,m) scanf("%lld %lld",&n,&m)

#define s2lu(n,m) scanf("%llu %llu",&n,&m)

#define s2d(n,m) scanf("%lf %lf",&n,&m)

//inputs 3 var

#define s3i(n,m,l) scanf("%d %d %d",&n,&m,&l)

#define s3u(n,m,l) scanf("%u %u %u",&n,&m,&l)

#define s3l(n,m,l) scanf("%lld %lld %lld",&n,&m,&l)

#define s3lu(n,m,l) scanf("%llu %llu %llu",&n,&m,&l)

#define s3d(n,m,l) scanf("%lf %lf %lf",&n,&m,&l)



//output 1 var

#define p1i(n) printf("%d",n)

#define p1u(n) printf("%u",n)

#define p1l(n) printf("%lld",n)

#define p1lu(n) printf("%llu",n)

#define p1d(n,pre) printf("%.*f",pre,n)

#define p1s(n) printf("%s",n)

//output 2 var

#define p2i(n,m) printf("%d %d",n,m)

#define p2u(n,m) printf("%u %u",n,m)

#define p2l(n,m) printf("%lld %lld",n,m)

#define p2lu(n,m) printf("%llu %llu",n,m)

#define p2d(n,m,pre) printf("%.*f %.*f",pre,n,pre,m)

//inputs 3 var less important

#define p3i(n,m,l) printf("%d %d %d",n,m,l)

#define p3u(n,m,l) printf("%u %u %u",n,m,l)

#define p3l(n,m,l) printf("%lld %lld %lld",n,m,l)

#define p3lu(n,m,l) printf("%llu %llu %llu",n,m,l)

//output misc

#define nline() putchar(10)

#define space() putchar(' ')

#define pch(c) putchar(c)

#define tcase(i) printf("Case %d:",i)

//loop

#define fr0(i,n) for(i=0;i<n;i++)

#define fr1(i,n) for(i=1;i<=n;i++)

//memory reset

#define set0(x) memset(x,0,sizeof x)

#define setn1(x) memset(x,-1,sizeof x)

#define setinf(x) memset(x,125,sizeof x)

//bit operation single variable

#define On(x,i)  (x|=(1<<(i)))

#define Off(x,i) (x&= ~(1<<(i)))

#define isOn(x,i) (x&(1<<(i)))

#define Toggle(x,i) (x^=(1<<(i)))

#define tmod(x,i)  (x&(~(-1<<i)))



//data type

typedef long long ll;

typedef unsigned long long ull;

//bit operation array

//constant

const double EPS = 1e-9;

using namespace std;

int tc,o,prc,sld,i,j,r,c,x,y;



char B[250][250];

queue<pair<int,int> > q;

map<pair<int,int> ,int> level,visited;

pair<int,int>u;

main()

{

    {

        s2i(r,c);

        fr0(i,r)

        {

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

            fr0(j,c)

            {

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

                {

                    x=i,y=j;continue;

                }

            }

        }

        q.push(mp(x,y));

        level[mp(x,y)]=0;

        visited[mp(x,y)]=1;

        sld=5000;prc=50000;

        while(!q.empty())

        {

            u=q.front();q.pop();

            if(B[u.f][u.s]=='@')prc=level[u];

            if(B[u.f][u.s]=='$')sld=min(sld,level[u]);



            if(u.f+1<r && B[u.f+1][u.s]!='#' && !visited[mp(u.f+1,u.s)])

            {

                level[mp(u.f+1,u.s)]=level[u]+1;

                visited[mp(u.f+1,u.s)]=1;

                q.push(mp(u.f+1,u.s));

            }



            if(u.s+1<c && B[u.f][u.s+1]!='#' && !visited[mp(u.f,u.s+1)])

            {

                level[mp(u.f,u.s+1)]=level[u]+1;

                visited[mp(u.f,u.s+1)]=1;

                q.push(mp(u.f,u.s+1));

            }





            if(u.f-1>=0 && B[u.f-1][u.s]!='#' && !visited[mp(u.f-1,u.s)])

            {

                level[mp(u.f-1,u.s)]=level[u]+1;

                visited[mp(u.f-1,u.s)]=1;

                q.push(mp(u.f-1,u.s));

            }



            if(u.s+1>=0 && B[u.f][u.s-1]!='#' && !visited[mp(u.f,u.s-1)])

            {

                level[mp(u.f,u.s-1)]=level[u]+1;

                visited[mp(u.f,u.s-1)]=1;

                q.push(mp(u.f,u.s-1));

            }

        }

        if(prc<sld)printf("Yes\n");

        else printf("No\n");



    }

}

// Fastest known solution for this problem: