What is wrong is this?
Use these conditions
if(S<K)
{
break;
}
else
if(ar[i][j]==ā.ā)
{
S=S-2;
Sā;
}
else
if(ar[i][j]==ā*ā)
{
S=S+5;
Sā;
}
else
if(ar[i][j]==ā#ā)
{
N=N+1;
}
else
if(ar[i][j]==ā#ā && i==N-1)
{
break;
}
and then try to submit your code