/************************************
 *  Event  :      Interuni 2009, Vologda
 *  Problem:      Spiral
 *  Author:       Pavel Kuznetsov
 *  Last update:  2000.02.23 14:52
 ************************************
*/

#include <map> 
#include <set> 
#include <queue> 
#include <stdio.h>
#include <bitset> 
#include <valarray> 
#include <complex> 
#include <iostream> 
#include <sstream> 
#include <cmath> 
#include <algorithm> 
#include <string> 
#include <cassert> 

using namespace std;

// prewritten code

#define Size(x) (int)(x).size()
#define For(i,a,b) for(int i=(int)(a);i<=(int)(b);++i)
#define Ford(i,a,b) for(int i=(int)(a);i>=(int)(b);--i) 
#define RepV(i,v) for (int i=0;i<Size(v);++i)
#define All(c) (c).begin(),(c).end()
#define Fill(a,b) memset(&a,b,sizeof(a))
#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
#define Abs(a) ((a)<0?-(a):(a))
#define VVI vector<vector<int> >
#define VI vector<int>
#define VVS vector<vector<string> >
#define VS vector<string>
#define ForEach(it,a) for (typeof((a).begin()) it=(a).begin(); it!=(a).end(); ++it)
#define DBG(x) cout << #x <<" = "<< x << endl;
#define DBGA(x) {cout << #x <<": "; for (int i=0; i<(int)sizeof(x)/(int)sizeof(x[0]); ++i) cout<<x[i]<<' '; cout<<endl;}
#define DBGV(x) {cout << #x <<": "; for (int i=0; i<(int)Size(x); ++i) cout<<x[i]<<' '; cout<<endl;}

const string problem_name = "spiral";

const int MINN = 1;
const int MAXN = 1000;

void get_coord(int n, int &x, int &y){
	if (n==0) { x=0; y=0; return; }
	int k = (int)sqrt(n+0.0);
	if (k%2==0) --k;
	int ring = (k+1)/2;
	
	int corner1=k*k+k, corner1_x=ring, corner1_y=-ring;
	int corner2=corner1+ring*2, corner2_x=-ring, corner2_y=-ring;
	int corner3=corner2+ring*2, corner3_x=-ring, corner3_y=ring;
	int corner4=corner3+ring*2, corner4_x=ring, corner4_y=ring;
	
	if (n <= corner1) {
		x = corner1_x; y = corner1_y + (corner1-n);
	} else if (n <= corner2){
		x = corner2_x+(corner2-n); y = corner2_y;
	} else if (n <= corner3){
		x = corner3_x; y = corner3_y - (corner3-n);
	} else {
		x = corner4_x-(corner4-n); y = corner4_y;
	}
}

int main(){
//	freopen((problem_name+".in").c_str(),"rt",stdin);
//	freopen((problem_name+".out").c_str(),"wt",stdout);
	
	int n;
	cin >> n;
	
	assert( MINN <= n && n <= MAXN);
	
	For(i,0,n) {
		int x1, x2, y1, y2;
		get_coord(i,x1,y1);
		get_coord(n-i,x2,y2);
		if (Max(Abs(x1-x2),Abs(y1-y2)) < 2) {
			printf("%d %d",i,n-i);
			return 0;
		}
	}
	
	printf("0 0");
	
	return 0;
}
