//The Problem 3
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define M(a) memset(a,0,sizeof a)
#define fo(i,j,k) for(i=j;i<=k;i++)
using namespace std;
const double PI=acos(-1.0);
const int mxn=55;
char s[15];
int n,back,to;
int jiao[55];
int f[19000];
inline int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int main()
{
int i,j,x,t1,t2,p,mn=180;
double v=0.0,ot;
n=read();
fo(i,1,n)
{
scanf("%s",s);
x=read();
if(s[0]=='f') to+=x;
else if(s[0]=='l') jiao[++jiao[0]]=x%360;
else if(s[0]=='r')
{
x=-x;
while(x<0) x+=360;
jiao[++jiao[0]]=x;
}
else back+=x;
}
if(to>back) v+=to,ot=back;
else v+=back,ot=to;
f[0]=1;
fo(i,1,jiao[0])
for(j=18000;j>=jiao[i];j--)
f[j]=max(f[j],f[j-jiao[i]]);
fo(j,0,18000)
if(f[j])
if(abs(180-(j%360))<mn)
mn=abs(180-(j%360));
double ang=mn;
v=v+ot*(cos(ang*PI/180.0));
double tmp=ot*(sin(ang*PI/180.0));
v=sqrt(v*v+tmp*tmp);
printf("%f\n",v);
return 0;
}