//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
#define x first
#define y second
#define x1 x114514
#define x2 x1919810
#define y1 y114514
#define y2 y1919810
#define index _index
typedef long double ldb;
void die(string S){puts(S.c_str());exit(0);}
const ldb eps=1e-16;
struct line
{
ldb A,B,C;
line(ldb _A,ldb _B,ldb _C):A(_A),B(_B),C(_C){}
line(){}
}L[1010];
int x1,x2,y1,y2;
string s;
struct formula
{
formula *a,*b;
int op;
};
const pair<ldb,ldb> error=mp(20210109,20210448);
pair<ldb,ldb> its(line a,line b)
{
ldb B=a.B*b.A-b.B*a.A,C=a.C*b.A-b.C*a.A;
ldb y=-C/B;
ldb x=(-a.C-a.B*y)/a.A;
if(fabs(B)<eps) return error;
if(fabs(a.A)<eps) x=(-b.C-b.B*y)/b.A;
return mp(x,y);
}
int tot;
formula *get(int l,int r)
{
int c=0,p=-1;
for(int i=l;i<=r;i++)
{
if(s[i]=='(')
c++;
if(s[i]==')')
c--;
if(s[i]=='!'||s[i]=='&'||s[i]=='|'||s[i]=='^') if(!c)
p=i;
}
if(p==-1)
{
if(s[l]=='(')
return get(l+1,r);
formula *ret=new formula;
ret->op=++tot;
vector<int> vec;
int x=0,f=0;
for(int i=l;i<=r;i++)
{
if(isdigit(s[i]))
{
x=x*10+(s[i]^48);
if(!f) f=1;
}
else if(s[i]=='-')
f=-1;
else if(f)
{
vec.pb(x*f);
x=0;
f=0;
}
}
assert(sz(vec)==3);
L[tot]=line(vec[0],vec[1],vec[2]);
return ret;
}
else
{
if(s[p]=='!')
{
formula *ret=new formula;
ret->op=-4;
ret->a=get(l+1,r);
return ret;
}
formula *ret=new formula;
ret->op=(s[p]=='&'?-1:(s[p]=='|'?-2:-3));
ret->a=get(l,p-1);
ret->b=get(p+1,r);
return ret;
}
}
vector<pair<pair<ldb,ldb>,pii>> vec;
int lst[1010];
vector<pair<ldb,int>> G[100100];
ldb calc(int a,int b)
{
return atan2(vec[b].x.y-vec[a].x.y,vec[b].x.x-vec[a].x.x);
}
map<int,int> index[100100];
map<pii,bool> vis;
bool status[100100];
pair<ldb,ldb> ctr(pair<ldb,ldb> a,pair<ldb,ldb> b,pair<ldb,ldb> c)
{
return mp((a.x+b.x+c.x)/3,(a.y+b.y+c.y)/3);
}
bool calc(formula *F)
{
if(F->op>0) return status[F->op];
if(F->op==-4) return !calc(F->a);
bool a=calc(F->a),b=calc(F->b);
if(F->op==-1) return a&b;
if(F->op==-2) return a|b;
return a^b;
}
map<pair<ldb,ldb>,vector<int>> belong;
const bool operator ==(const pair<ldb,ldb> &a,const pair<ldb,ldb> &b)
{
return fabs(a.x-b.x)<eps&&fabs(a.y-b.y)<eps;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>x1>>x2>>y1>>y2;
cin>>s;
if(!s)
cout<<(x2-x1)*(y2-y1)<<endl;
formula *F=get(0,sz(s)-1);
L[tot+1]=line(1,0,-x1);
L[tot+2]=line(0,-1,y2);
L[tot+3]=line(-1,0,x2);
L[tot+4]=line(0,1,-y1);
int cnt=0;
for(int i=1;i<=tot+4;i++)
for(int j=i+1;j<=tot+4;j++)
{
pair<ldb,ldb> p=its(L[i],L[j]);
if(p==error) continue;
if(p.x<x1-eps||p.x>x2+eps||p.y<y1-eps||p.y>y2+eps)
continue;
belong[p].pb(i);
belong[p].pb(j);
vec.pb(p,mp(0,0));
}
srt(vec);
uni(vec);
int n=sz(vec);
memset(lst,-1,sizeof(lst));
vector<int> ban;
for(int i=0;i<n;i++)
{
auto pr=vec[i];
bool flag=0;
srt(belong[pr.first]);
uni(belong[pr.first]);
for(auto a:belong[pr.first])
{
if(a>tot) flag=1;
if(lst[a]!=-1)
{
G[lst[a]].pb(calc(lst[a],i),i);
G[i].pb(calc(i,lst[a]),lst[a]);
}
lst[a]=i;
}
if(flag)
ban.pb(i);
}
for(int i=0;i<n;i++)
{
srt(G[i]);
for(int j=0;j<sz(G[i]);j++)
index[i][G[i][j].second]=j;
}
srt(ban);
vector<array<int,3>> pool;
for(int i=0;i<n;i++)
for(auto pr:G[i])
if(!vis[mp(i,pr.second)])
{
vector<int> cvh;
int cura=i,curb=pr.second;
while(!vis[mp(cura,curb)])
{
vis[mp(cura,curb)]=1;
cvh.pb(curb);
int p=index[curb][cura];
p=(p+1)%sz(G[curb]);
cura=curb;
curb=G[cura][p].second;
}
if(sz(cvh)<3) continue;
vector<int> tmp=cvh;
srt(tmp);
if(tmp==ban)
{
ban.clear();
continue;
}
for(int i=2;i<sz(cvh);i++)
pool.push_back({cvh[0],cvh[i-1],cvh[i]});
}
ldb ans=0;
for(auto arr:pool)
{
int a=arr[0],b=arr[1],c=arr[2];
pair<ldb,ldb> center=ctr(vec[a].first,vec[b].first,vec[c].first);
memset(status,0,sizeof(status));
for(int i=1;i<=tot;i++)
if(L[i].A*center.x+L[i].B*center.y+L[i].C>-eps)
status[i]=1;
if(calc(F))
{
ldb S=0;
ldb ax=vec[a].x.x-vec[c].x.x,ay=vec[a].x.y-vec[c].x.y,bx=vec[b].x.x-vec[c].x.x,by=vec[b].x.y-vec[c].x.y;
S=fabs(ax*by-ay*bx)/2;
ans+=S;
}
}
printf("%.20Lf\n",ans);
return 0;
}