#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  while (scanf("%I64d", &n) != EOF) {
    long long x, y, l, h, mid;
    l = 0, h = 1e18 + 7;
    while (l < h - 1) {
      mid = (l + h) >> 1;
      if (n / (3 * mid) >= mid + 1)
        l = mid;
      else
        h = mid;
    }
    x = 2 * l;
    y = 0;
    long long ret = n - 3 * l * (l + 1);
    l++;
    if (ret >= 1) {
      x++;
      y += 2;
      if (ret <= l) {
        x -= ret - 1;
        y += 2 * (ret - 1);
      } else {
        x -= l - 1;
        y += 2 * (l - 1);
        if (ret <= 2 * l) {
          x -= 2 * (ret - l);
        } else {
          x -= 2 * l;
          if (ret <= 3 * l) {
            x -= ret - 2 * l;
            y -= 2 * (ret - 2 * l);
          } else {
            x -= l;
            y -= 2 * l;
            if (ret <= 4 * l) {
              x += ret - 3 * l;
              y -= 2 * (ret - 3 * l);
            } else {
              x += l;
              y -= 2 * l;
              if (ret <= 5 * l) {
                x += 2 * (ret - 4 * l);
              } else {
                x += 2 * l;
                x += ret - 5 * l;
                y += 2 * (ret - 5 * l);
              }
            }
          }
        }
      }
    }
    printf("%I64d %I64d\n", x, y);
  }
  return 0;
}
