#include <bits/stdc++.h>
using namespace std;
long long n,d[1000][1000],res=0,x,y;
long long d1,d2;
void loang(long long i,long long j)
{
if (i>=1 && j>=1 && i<=n && j<=n)
if (i!=d1 && j!=d2)
{
if (d[i][j]==0)
{
d[i][j]=1;
loang(i+2,j-1);
loang(i+2,j+1);
loang(i+1,j-2);
loang(i+1,j+2);
loang(i-2,j+1);
loang(i-2,j-1);
loang(i-1,j+2);
loang(i-1,j-2);
d[i][j]=0;
}}
else
res+=1;
}
int main() {
freopen("madituan.inp","r",stdin);
freopen("madituan.out","w",stdout);
cin>>n;
cin>>x>>y;
cin>>d1>>d2;
loang(x,y);
cout<<res;
return 0;}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmxvbmcgbG9uZyBuLGRbMTAwMF1bMTAwMF0scmVzPTAseCx5Owpsb25nIGxvbmcgZDEsZDI7CnZvaWQgbG9hbmcobG9uZyBsb25nIGksbG9uZyBsb25nIGopCnsKICAgIGlmIChpPj0xICYmIGo+PTEgJiYgaTw9biAmJiBqPD1uKQogICAgICAgIGlmIChpIT1kMSAmJiBqIT1kMikKICAgICAgICB7CiAgICAgICAgICAgIGlmIChkW2ldW2pdPT0wKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZFtpXVtqXT0xOwogICAgICAgICAgICAgICAgbG9hbmcoaSsyLGotMSk7CiAgICAgICAgICAgICAgICBsb2FuZyhpKzIsaisxKTsKICAgICAgICAgICAgICAgIGxvYW5nKGkrMSxqLTIpOwogICAgICAgICAgICAgICAgbG9hbmcoaSsxLGorMik7CiAgICAgICAgICAgICAgICBsb2FuZyhpLTIsaisxKTsKICAgICAgICAgICAgICAgIGxvYW5nKGktMixqLTEpOwogICAgICAgICAgICAgICAgbG9hbmcoaS0xLGorMik7CiAgICAgICAgICAgICAgICBsb2FuZyhpLTEsai0yKTsKICAgICAgICAgICAgICAgIGRbaV1bal09MDsKICAgIH19CiAgICBlbHNlCiAgICAgICAgcmVzKz0xOwp9CmludCBtYWluKCkgewogICAgZnJlb3BlbigibWFkaXR1YW4uaW5wIiwiciIsc3RkaW4pOwogICAgZnJlb3BlbigibWFkaXR1YW4ub3V0IiwidyIsc3Rkb3V0KTsKICAgIGNpbj4+bjsKICAgIGNpbj4+eD4+eTsKICAgIGNpbj4+ZDE+PmQyOwogICAgbG9hbmcoeCx5KTsKICAgIGNvdXQ8PHJlczsKICAgIHJldHVybiAwO30K