#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int INF = 1000000007;
const int MOD = 1000000007;
const int MAXN = 100055;
int dx[] = {2, 1, -1, -2, -1, 1, 2, 1, -1};
int dy[] = {0, 2, 2, 0, -2, -2, 0, 2, 2};
int main() {
  long long n;
  while (cin >> n) {
    n++;
    if (n == 1) {
      cout << "0 0" << endl;
      continue;
    }
    long long L = (n - 1 + 2) / 3;
    L = sqrt(L + 0.5);
    while (3 * L * (L + 1) + 1 < n) ++L;
    n -= 3 * L * (L - 1) + 1;
    int side = (n - 1) / L;
    n -= L * side;
    long long ansx = dx[side] * L + dx[side + 2] * n;
    long long ansy = dy[side] * L + dy[side + 2] * n;
    cout << ansx << " " << ansy << endl;
  }
  return 0;
}
