// InterestingLSY
// 2659723130
// 《幽灵公主》是真的好看！
#include <bits/stdc++.h>
using namespace std;
#define il inline
#define elif else if

// Type
#define ld double
#define ll long long
#define ull unsigned ll

// Vector
#define vc vector
#define Pb push_back
#define Pf push_front
#define Eb emplace_back
#define All(x) x.begin(),x.end()
#define AllRev(x) x.rbegin(),x.rend()

// Memory
#define Ms(_data) memset(_data,0,sizeof(_data))
#define Msn(_data,_num) memset(_data,_num,sizeof(_data))

// Template
#define _cl class
#define _tp template
#define _tyn typename

// Pair
#define Mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>

// Loop
#define For(i,j) for( int (i) = 1 ; (i) <= (j) ; ++(i) )
#define For0(i,j) for( int (i) = 0 ; (i) < (j) ; ++(i) )
#define Forx(i,j,k) for( int (i) = (j) ; (i) <= (k) ; ++(i) )
#define Forstep(i,j,k,st) for( int (i) = (j) ; (i) <= (k) ; (i) += (st) )
#define fOR(i,j) for( int (i) = (j) ; (i) >= 1 ; --(i) )
#define fOR0(i,j) for( int (i) = (j)-1 ; (i) >= 0 ; --(i) )
#define fORx(i,j,k) for( int (i) = (k) ; (i) >= (j) ; --(i) )

// Read
struct InputReader{
	#define bs 1048576
	char buf[bs]; int p;
	il InputReader(){ p = bs; }
	il void Flush(){ p = 0; fread(buf,1,bs,stdin); }
	il char C(){ if(p >= bs) Flush(); return buf[p++]; }
	il char Readnum(){ char ch = C(); while( !isdigit(ch) && ch != '-' ) ch = C(); return ch; }
	il void Readalpha( char &c ){ c = C(); while( !isalpha(c) ) c = C(); }
	int operator() (){
		int ans = 0, fu = 1; char ch = Readnum();
		if( ch == '-' ) fu = -1, ch = C();
		while( ch >= '0' && ch <= '9' ){
			ans = ans*10 + ch-'0';
			ch = C();
		}
		return ans * fu;
	}
	ll Readll(){
		ll ans = 0LL, fu = 1LL; char ch = Readnum();
		if( ch == '-' ) fu = -1LL, ch = C();
		while( ch >= '0' && ch <= '9' ){
			ans = ans*10LL + ch-'0';
			ch = C();
		}
		return ans * fu;
	}
	il void Readstring( string &x ){
		x.clear(); char ch = C();
		while( !isdigit(ch)  &&  !isalpha(ch)  &&  ch != '#'  &&  ch != '.' ) ch = C();
		while( isdigit(ch)  ||  isalpha(ch)  ||  ch == '#'  ||  ch == '.' ){
			x += ch;
			ch = C();
		}
	}
	il void Readchstring( char s[] ){
		int len = 0; char ch = C();
		while( !isdigit(ch)  &&  !isalpha(ch)  /*&&  ch != '*'  &&  ch != '?'*/ ) ch = C();
		while( isdigit(ch)  ||  isalpha(ch)  /*||  ch == '*'  ||  ch == '?'*/ ){
			s[len++] = ch;
			ch = C();
		}
		s[len] = '\0';
	}
	il void Specialread( char &c ){
		c = C();
		while( !isdigit(c) && !isalpha(c) && c != '#'  &&  c != '.'  &&  c != '='  &&  c != 'B' ) c = C();
	}
	#undef bs
}In;
il void Read( int &x ){ x = In(); }
il void Read( int &x, int &y ){ x = In(); y = In(); }
il void Read( int &x1 , int &x2 , int &x3 ){ x1 = In(); x2 = In(); x3 = In(); }
il void Read( int &x1 , int &x2 , int &x3 , int &x4 ){ x1 = In(); x2 = In(); x3 = In(); x4 = In(); }
il void Read( ll &x ){ x = In.Readll(); }
il void Read( ll &x, ll &y ){ x = In.Readll(); y = In.Readll(); }
il void Read( ll &x1 , ll &x2 , ll &x3 ){ x1 = In.Readll(); x2 = In.Readll(); x3 = In.Readll(); }
il void Read( ll &x1 , ll &x2 , ll &x3 , ll &x4 ){ x1 = In.Readll(); x2 = In.Readll(); x3 = In.Readll(); x4 = In.Readll(); }
_tp<_tyn T> void Read( T a[] , int st , int ed ){ Forx(i,st,ed) Read(a[i]); }
#define iRead(k) int k; Read(k);
#define iRead2(a,b) iRead(a); iRead(b);
#define iRead3(a,b,c) iRead2(a,b); iRead(c);
#define iRead4(a,b,c,d) iRead2(a,b); iRead2(c,d);
#define lRead(k) ll k; Read(k);
#define lRead2(a,b) lRead(a); lRead(b);
#define lRead3(a,b,c) lRead2(a,b); lRead(c);
#define lRead4(a,b,c,d) lRead2(a,b); lRead2(c,d);

// File
#define Fin(a) freopen(a,"r",stdin)
#define Fout(a) freopen(a,"w",stdout)
il void FILEIO(){
	#ifdef intLSY
		Fin("in.in");
	#endif
}
il void FILEIO( string pname ){
	#ifndef intLSY
		Fin((pname+".in").c_str());
		Fout((pname+".out").c_str());
	#else
		Fin("in.in");
	#endif
}
il void FILEIO_OICONTEST( string pname ){
	Fin((pname+".in").c_str());
	#ifndef intLSY
		Fout((pname+".out").c_str());
	#endif
}
void Printtime(){
	#ifdef intLSY
		double _timeuse = clock()* 1000.0 / CLOCKS_PER_SEC;
		fprintf(stderr,"\n\nTime usage:\n%.0lf ms\n",_timeuse);
	#endif
}
void END(){ Printtime(); exit(0); }
_tp<_tyn T>void END( T mes ){ cout << mes << endl; END(); }

// Debug
#define B cerr << "BreakPoint" << endl;
#define O(x) cerr << #x << " " << (x) << endl;
#define o(x) cerr << #x << " " << (x) << "  ";
#define Msz(x) cerr << "Sizeof " << #x << " " << sizeof(x)/1024/1024 << " MB" << endl;
_tp<_tyn T>void Print( T a[] , int s , int t , char sp = ' ' , char ed = '\n' ){
	if( s > t ) return;
	for( int i = s ; i < t ; i++ )
		cout << a[i] << sp;
	cout << a[t] << ed;
	cout.flush();
}
_tp<_tyn T>void Print( T a , int s = 0 , int t = -1 , char sp = ' ' , char ed = '\n' ){
	if( t == -1 ) t = a.size()-1;
	for( int i = s ; i <= t ; i++ )
		cout << a[i] << sp;
	cout << ed;
	cout.flush();
}

// Optimize
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define Mymax(a,b) (a) = max((a),(b))
#define Mymin(a,b) (a) = min((a),(b))
#define MyMax(a,b) (a) = Max((a),(b))
#define MyMin(a,b) (a) = Min((a),(b))
#define INF (0x3f3f3f3f)
#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))
#define Sqr(x) ((x)*(x))
#define Lowbit(a) ((a)&(-(a)))
vc<int> Range( int l , int r ){
	vc<int> ret{};
	Forx(i,l,r) ret.Pb(i);
	return ret;
}
mt19937 Rand(0xe38195e38293*time(0));	// さん
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
#undef ld
#define ld long double
const ld Eps = 1e-10;
il ld Sqrt( ld x ){
	assert( x > -Eps );
	return x < Eps ? 0 : sqrt(x);
}
struct Point{
	ld x,y;
	il ld Len2(){ return x*x+y*y; }
	il ld Len(){ return Sqrt(x*x+y*y); }
};
il Point operator+( const Point &a , const Point &b ){ return {a.x+b.x,a.y+b.y}; }
il Point operator-( const Point &a , const Point &b ){ return {a.x-b.x,a.y-b.y}; }
il auto operator^( const Point &a , const Point &b ){ return a.x*b.x + a.y*b.y; }
il auto operator*( const Point &a , const Point &b ){ return a.x*b.y - b.x*a.y; }
il Point operator*( const Point &a , const ld &b ){ return {a.x*b,a.y*b}; }
il Point operator/( const Point &a , const ld &b ){ return {a.x/b,a.y/b}; }
il bool operator==( const Point &a , const Point &b ){ return fabs(a.x-b.x)<Eps and fabs(a.y-b.y)<Eps; }
il ld Dis( const Point &a , const Point &b ){ return Sqrt((ld)Sqr(a.x-b.x)+Sqr(a.y-b.y)); }
il ld Dis2( const Point &a , const Point &b ){ return Sqr(a.x-b.x)+Sqr(a.y-b.y); }
ostream& operator<<( ostream &out , const Point &p ){
	out << p.x << " " << p.y << "  ";
	return out;
}
il bool OnSeg( const Point &a , const Point &b , const Point &c ){
	Point ab = b-a, ac = c-a;
	if( fabs(ab*ac) > Eps ) return 0;
	if( (ab^ac) < -Eps ) return 0;
	if( fabs(ab.y*ab.y+ab.x*ab.x)-Eps > fabs(ac.y*ac.y+ac.x*ac.x) ) return 0;
	// cout << a.x << " " << a.y << "  " << b.x << " " << b.y << "  " << c.x << " " << c.y << endl;
	return 1;
}
bool Ins( Point p1 , Point p2 , Point p3 , Point p4 ){
	if( p1 == p3 or p1 == p4 or p2 == p3 or p2 == p4 ) return 1;
	if( OnSeg(p1,p3,p2) or OnSeg(p1,p4,p2) or OnSeg(p3,p1,p4) or OnSeg(p3,p2,p4) ) return 1;
	if( ((p2-p1)*(p3-p1)<-Eps) == ((p2-p1)*(p4-p1)<-Eps) ) return 0;
	if( ((p4-p3)*(p1-p3)<-Eps) == ((p4-p3)*(p2-p3)<-Eps) ) return 0;
	return 1;
}
Point InsPoint( Point p1 , Point p2 , Point p3 , Point p4 ){
	ld d1 = (ld)abs((p2-p3)*(p3-p1)) / Dis(p1,p2);
	ld d2 = (ld)abs((p2-p4)*(p4-p1)) / Dis(p1,p2);
	ld ratio = d1 / (d1+d2);
	return (p4-p3)*ratio + p3;
}
Point H( Point a , Point b , Point p ){
	Point ab = b-a;
	ld dis2 = Dis2(a,b);
	Point ret = a + ab * (((p-a)^ab)/dis2);
	return ret;
}
ld Distance( Point p1 , Point p2 , Point p3 , Point p4 ){
	if(Ins(p1,p2,p3,p4)) return 0;
	ld ans = min({ Dis(p1,p3) , Dis(p1,p4) , Dis(p2,p3) , Dis(p2,p4) });
	auto Check = [&]( Point a , Point b , Point p ){
		Point h = H(a,b,p);
		if(!OnSeg(a,h,b)) return;
		ld tans = Dis(h,p);
		Mymin(ans,tans);
	};
	Check(p1,p2,p3);
	Check(p1,p2,p4);
	Check(p3,p4,p1);
	Check(p3,p4,p2);
	return ans;
}
Point Rotate( Point v , ld sinres , ld cosres ){
	assert( fabs(cosres) > Eps or fabs(sinres) > Eps );
	assert( v.Len2() > Eps );
	assert( fabs(Sqr(sinres)+Sqr(cosres)-1) < Eps );
	if( fabs(cosres) < Eps ){
		Point ans = sinres > 0 ? Point{-v.y,v.x} : Point{v.y,-v.x};
		ans = ans / ans.Len();
		return ans;
	}elif( fabs(sinres) < Eps ){
		Point ans = cosres > 0 ? v : v*(-1);
		ans = ans / ans.Len();
		return ans;
	}
	v = v * (cosres/v.Len());
	Point rot{-v.y,v.x};
	rot = rot * (sinres/cosres);
	Point p = v + rot;
	assert( fabs(p.Len2()-1) < Eps );
	return p;
}
pair<Point,Point> CycCross( Point o , ld r , Point p1 , Point p2 ){
	Point p1p2 = p2-p1;
	p1 = p1-p1p2*(1e6);
	p2 = p2+p1p2*(1e6);
	Point h = H(p1,p2,o);
	Point oh = h-o;
	ld tlen = sqrt( r*r - oh.Len2() );
	Point add = (p1-h) / (p1-h).Len() * tlen;
	Point a1 = h+add, a2 = h-add;
	return {a1,a2};
}
Point CycCross_( Point o , ld r , Point p1 , Point p2 ){
	auto res = CycCross(o,r,p1,p2);
	Point a1 = res.F, a2 = res.S;
	if( OnSeg(p1,a1,p2) ) return a1;
	if( OnSeg(p1,a2,p2) ) return a2;
	assert(0);
}

ld r;
const ld PI = 3.141592653589793238462643383279;

ld Calc( Point a , Point b ){
	ld len = Dis(a,b);
	ld h = Sqrt( r*r - Sqr(len/2) );
	ld cyc = PI*r*r * (asin(len/2/r)/PI);
	ld ans = cyc*2;
	return ans;
}
ld Calc2( Point a , Point b ){
	ld len = Dis(a,b);
	ld h = H(a,b,{0,0}).Len();
	return Calc(a,b) - len*h;
}
ld Helper( Point p1 , Point p2 ){
	Point a = CycCross_({0,0},r,{0,0},p1);
	Point b = CycCross_({0,0},r,{0,0},p2);
	ld ans = Calc(a,b);
	if( H(p1,p2,{0,0}).Len2() < r*r-Eps ){
		auto res = CycCross({0,0},r,p1,p2);
		if( OnSeg(p1,res.F,p2) and OnSeg(p1,res.S,p2) )
			ans -= Calc2(res.F,res.S);
	}
	return ans;
}

ld Solve( Point p2 , Point p3 );

ld Solve_( Point p2 , Point p3 ){
	if( max(p2.Len2(),p3.Len2()) < r*r+Eps ) return fabs(p2*p3);
	if( min(p2.Len2(),p3.Len2()) > r*r-Eps ){
		return Helper(p2,p3);
	}
	if( p2.Len2() > p3.Len2() ) swap(p2,p3);
	Point a = CycCross_({0,0},r,p2,p3);
	Point b = CycCross_({0,0},r,{0,0},p3);
	return Calc(a,b) + Solve(p2,a);
}

ld Solve( Point p2 , Point p3 ){
	ld ans = Solve_(p2,p3);
	// cout << p2 << p3 << "  " << ans << endl;
	return ans;
}

int main(){
	FILEIO();

	int n;
	vc<Point> a;
	cin >> n >> r;
	For(i,n){
		ld x,y; cin >> x >> y;
		a.Pb({x,y});
	}
	a.Pb(a[0]);

	ld ans = 0;
	For0(i,n){
		Point p1 = {0,0}, p2 = a[i], p3 = a[i+1];
		if( fabs((p2-p1)*(p3-p1)) < Eps ) continue;
		ld tans = Solve(p2,p3);
		// cout << p2 << p3 << tans << endl;
		if( (p2-p1)*(p3-p1) < 0 ) tans = -tans;
		ans += tans/2;
	}
	cout << setprecision(12) << fixed;
	cout << ans << endl;

	END();
}



Measured memory_bytes: 3420