import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
    long N = s.nextLong();
    long n = 0;
    long sum = 0;
    while(sum<N){
        n++;
    	sum = n*(n+1)/2;

    }
    if(sum==N){
    	System.out.println(n);
    }
    else{
        n--;
        sum = n*(n+1)/2;
        System.out.println(N-sum);
    }

    }
}

import java.util.Scanner;
public class InfiniteSequence {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();

		long ans = (long) Math.sqrt(n * 2);
		if (ans * (ans + 1) / 2 < n) {
			ans++;
		}
		long sum = ans * (ans + 1) / 2;
		System.out.println(ans - (sum - n));
		/*long x = 0;
		long sum = 0;

		while (sum < n) {
			x++;
			sum = sum + x;
		}
		System.out.println(x - (sum-n));*/
	}
}

import java.util.Scanner;
public class InfiniteSequence {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();

		long x = 0;
		long sum = 0;

		while (sum < n) {
			x++;
			sum = sum + x;
		}
		System.out.println(x - (sum-n));
	}
}

import java.util.Scanner;

public class problema1 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = 1;

		while(n - k > 0) {
			n -= k;
			k++;
		}

		System.out.println(n);
	}
}

import java.util.*;
import java.io.*;
import java.text.DecimalFormat;

public class CodeForces {

    static int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
    static int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

    public static void main(String[] args) throws IOException {
        Reader.init(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        long a = Reader.nextLong();
        long b = 0;
        long c = 0;

        for (int i = 1; ; i++) {
            if(b+i >= a)
                break;
            b += i;
        }

        System.out.println(a-b);
        writer.flush();
    }
}

class Edge implements Comparable<Edge> {

    int to;
    int from;
    int cost;

    Edge(int a, int b, int c) {
        from = a;
        to = b;
        cost = c;
    }

    @Override
    public int compareTo(Edge t) {
        return cost - t.cost;
    }
}

class Pair implements Comparable<Pair> {

    int x;
    int y;

    Pair(int a, int b) {
        x = a;
        y = b;
    }

    @Override
    public boolean equals(Object o) {
        return x == ((Pair) o).x && y == ((Pair) o).y;
    }

    @Override
    public int hashCode() {
        return 1;
    }

    @Override
    public int compareTo(Pair t) {
        if (x <= t.x && y <= t.y) {
            return 1;
        }
        return -1;
    }

}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    public static int pars(String x) {
        int num = 0;
        int i = 0;
        if (x.charAt(0) == '-') {
            i = 1;
        }
        for (; i < x.length(); i++) {
            num = num * 10 + (x.charAt(i) - '0');
        }

        if (x.charAt(0) == '-') {
            return -num;
        }

        return num;
    }

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static void init(FileReader input) {
        reader = new BufferedReader(input);
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return pars(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}

import java.io.IOException;
import java.util.Scanner;

public class C622 {

    public static void main(String[] args) throws IOException {
        Scanner input = new Scanner(System.in);
        long N = input.nextLong();
        long before = 0;
        long section = 1;
        while (before+section < N) {
            before += section;
            section++;
        }
        System.out.println(N-before);
    }

}

import java.util.*;

public class A7 {
	public static long getNumber(long x){
		long n = (long) Math.floor(Math.sqrt(2*x + .25) - 0.5);
		long sum = (n*(n+1)/2);
		if (sum == x) {
			return n;
		} else {
			return x - sum;
		}
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner (System.in);
		System.out.println(getNumber(scan.nextLong()));
	}
}

import java.util.Scanner;

public class Sequence {
    public static void main(String[] args) {
        long n;
        long index=0;
        Scanner input=new Scanner(System.in);
        n=input.nextLong();
        int i;
        for( i=1;index<n;i++){
            index+=i;
        }
        System.out.println((i-1)-(index-n));

    }
}

import java.io.*;
import java.util.*;

public class Send {
    private static InputReader in;

    public static void main(String[] args) {
        in = new InputReader(System.in);

        long k = in.nextLong();

        long t = (long) ((Math.sqrt(1 + 8 * k) - 1) / 2);
//        System.out.println(t);
//        System.out.println((Math.sqrt(1 + 8 * k) - 1) / 2);

        long sum = (long) (((double) (1 + t) / 2) * t);
        if (sum == k) {
            System.out.println(t);
        } else {
            System.out.println(k - sum);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}

import java.util.Scanner;

public class InfiniteSequence {

	public static void main(String... args) {

		Scanner sc = new Scanner(System.in);
		long num = sc.nextLong();
		sc.close();
		System.out.println(solve(num));

	}

	public static long solve(long n) {

		long i = 1;
		while (n > i) {
			n = n - i++;
		}

		return n;

	}
}

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
}

class Task {

    public void solve(InputReader in, OutputWriter out) {
        long n = in.nextLong();
        long x = (long) Math.ceil((1 + Math.sqrt(1 + 8 * n)) / (2.0)) - 1;

        x--;
        n -= ((1+x) * x) / 2;

        out.printLine(n);
    }

}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;
    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }
    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
    public boolean hasNext() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                String line = reader.readLine();
                if ( line == null ) {
                    return false;
                }
                tokenizer = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() { return Double.parseDouble(next());}
}
class OutputWriter {
    private final PrintWriter writer;
    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }
    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }
    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if ( i != 0 ) {
                writer.print(' ');
            }
            writer.print(objects[i]);
        }
    }
    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }
    public void close() {
        writer.close();
    }
}

import java.util.*;
public class InfinSeq
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        if(n == 1)
           System.out.println(n);
        else
        {
            long i = 1;
            while(n > i)
            {
                n -= i++;
            }
            System.out.println(n);
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

import javax.tools.ToolProvider;

public class knapsack {
	static int a[];
	static int n;
	static int memo[][];

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		int count=1;

		while(n-count>0) {
			n-=count;
			count++;
		}
		System.out.println(n);
	}

	static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

	}

}

/*
 * CSE 2013, NIT SILCHAR
 */
//package EducationalRound7;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author Nikhil Pathania
 */
public class A {
     public static void main(String args[]) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        long n=Long.parseLong(br.readLine());
        long x=n*2;
        long index=0;
        int max=Integer.MAX_VALUE;
        long ans=0;

        index=(int)Math.sqrt(x);
        //System.out.println(index);
        ans=index*(index+1)/2;
        if(ans==n)
        {
        System.out.println(index);
        }
        else if(ans>n)
        {
            ans=index*(index-1)/2;
            index=n-ans;
            System.out.println(index);
        }
        else if(n>ans)
        {
            index=n-ans;
            System.out.println(index);
        }
    }
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.lang.*;
public class me
{
 public static void main(String args[])
 {

                                  /*HERE IS THE CODE*/
                                    /*MAIN PROGRAM*/
  Scanner br=new Scanner(System.in);
        long l=br.nextLong();
        long i=1,s=0;
        while(s<l)
        {
            s=s+i;
            //System.out.println(s);
            i++;
        }if(s==l)
        System.out.print(i-1);
        else
        System.out.print(l-(s-i+1));

    }

    public static long  ways(int n, int r, long MOD)
    {
      //  vector<long long> f(n + 1,1);
        long f[]=new long[n+1];
        Arrays.fill(f,1);
        for (int i=2; i<=n;i++)
            f[i]= (f[i-1]*i) % MOD;
        return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
    }

                   /*THIS IS FOR THE INVERSE EULER*/
    public static long  InverseEuler(long n, long MOD)
    {
        return pow(n,MOD-2,MOD);
    }

                   /*THIS ID THE CHECK FOR THE PRIME*/
    static boolean isPrime(long number) {
        if (number <= 1) {
            return false;
        }
        if (number <= 3) {
            return true;
        }
        if (number % 2 == 0 || number % 3 == 0) {
            return false;
        }
        int i = 5;
        while (i * i <= number) {
            if (number % i == 0 || number % (i + 2) == 0) {
                return false;
            }
            i += 6;
        }
        return true;
    }

                          /*TO CHECK FOR THE GCD IN LONG*/
public static long gcd(long x,long y)
{
    if(x%y==0)
        return y;
    else
        return gcd(y,x%y);
}

                             /* CHECK FOR THE GCD IN INT*/
public static int gcd(int x,int y)
{
    if(x%y==0)
        return y;
    else
        return gcd(y,x%y);
}

                         /*CHECK FOR THE ABSOLUTE IN INT*/
public static int abs(int a,int b)
{
    return (int)Math.abs(a-b);
}

                        /*CHECK FOR THE ABSOLUTE IN LONG*/
public static long abs(long a,long b)
{
    return (long)Math.abs(a-b);
}

                       /*CHECK FOR MAX BETWEEN TWO NUMBERS IN INT*/
public static int max(int a,int b)
{
    if(a>b)
        return a;
    else
        return b;
}

                       /*CHECK FOR MIN BETWEEN TWO NUMBERS IN INT*/
public static int min(int a,int b)
{
    if(a>b)
        return b;
    else
        return a;
}

                       /*CHECK FOR MAX BETWEEN TWO NUMBERS IN LONG*/
public static long max(long a,long b)
{
    if(a>b)
        return a;
    else
        return b;
}

                     /*CHECK FOR MIN BETWEEN TWO NUMBERS IN LONG*/
public static long min(long a,long b)
{
    if(a>b)
        return b;
    else
        return a;
}
                    /*check for power of two of any num*/
static boolean isPowerOfTwo (long v) {
    return (v & (v - 1)) == 0;
}
public static long pow(long n,long p,long m)
{
     long  result = 1;
      if(p==0)
        return 1;
    if (p==1)
        return n;
    while(p!=0)
    {
        if(p%2==1)
            result *= n;
        if(result>=m)
        result%=m;
        p >>=1;
        n*=n;
        if(n>=m)
        n%=m;
    }
    return result;
}

                    /*SORT GIVEN ARRAY*/
static long sort(int a[],int n)
{   int b[]=new int[n];
    return mergeSort(a,b,0,n-1);}

static long mergeSort(int a[],int b[],long left,long right)
{ long c=0;if(left<right)
 {   long mid=left+(right-left)/2;
     c= mergeSort(a,b,left,mid);
     c+=mergeSort(a,b,mid+1,right);
     c+=merge(a,b,left,mid+1,right); }
    return c;    }

static long merge(int a[],int  b[],long left,long mid,long right)
{long c=0;int i=(int)left;int j=(int)mid; int k=(int)left;
while(i<=(int)mid-1&&j<=(int)right)
{ if(a[i]<=a[j]) {b[k++]=a[i++]; }
else    { b[k++]=a[j++];c+=mid-i;}}
while (i <= (int)mid - 1)   b[k++] = a[i++];
while (j <= (int)right) b[k++] = a[j++];
for (i=(int)left; i <= (int)right; i++)
    a[i] = b[i];  return c;  }

                       /*REMOVE ZERO FROM GIVEN NUM*/
static int removeZero(int num) {
        int ret = 0;
        int ten = 1;
        while (num>0) {
                int dig = num % 10;
                num /= 10;
                if (dig>0) {
                        ret += dig * ten;
                        ten *= 10;
                }
        }
        return ret;
}
                 /*CHECK FOR LCM*/
 static int lcm(int x, int y)
    {
        int a;
        a = (x > y) ? x : y; // a is greater number
        while(true)
        {
            if(a % x == 0 && a % y == 0)
                return a;
            ++a;
        }
    }
}

import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		long n = s.nextLong();
		int i=0;
		for(i=1;n>=1;i++)
			n-=i;
		System.out.println(n+i-1);
	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.IOException;
public class Main {
	public static void main(String[] args){
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		PrintStream output = new PrintStream(System.out);
		String kick = "";
		try{kick = input.readLine();}
		catch(IOException e1){e1.printStackTrace();}
		long n = Long.parseLong(kick);
		long num = -1;
		long i = 1;
		for( ; i <= n ; i+=num)num++;
		output.println(num-(i-n)+1);
	}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class infiniteSequence {
    static Scanner sc = new Scanner(System.in);
    static PrintWriter pw = new PrintWriter(System.out), pw2 = new PrintWriter(System.out);
    public static long bs(long x){
        long l=0,r=(int)1e14,ans=l;
        while(l<=r){
            long mid=(l+r)/2;
            if(sumNum(mid)>=x){
                ans=mid;
                r=mid-1;
            }else
                l=mid+1;
        }
        return ans;
    }
    public static void main(String[] args) throws IOException {
        long num=sc.nextLong();
        long x=bs(num);
        System.out.println(x-(sumNum(x)-num));
    }

    public static <E> void print2D(E[][] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                pw.println(arr[i][j]);
            }
        }
    }

    public static long digitSum(String s) {
        long toReturn = 0;
        for (int i = 0; i < s.length(); i++) toReturn +=Long.parseLong(s.charAt(i) + " ");
        return toReturn;
    }

    public static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;

        if (n % 2 == 0 || n % 3 == 0)
            return false;

        for (long i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        return true;
    }

    public static long pow(long a, long pow) {
        return pow == 0 ? 1 : pow % 2 == 0 ? pow(a * a, pow >> 1) : a * pow(a * a, pow >> 1);
    }

    public static long sumNum(long a) {
        return a * (a + 1) / 2;
    }

    public static int gcd(int n1, int n2) {
        return n2 == 0 ? n1 : gcd(n2, n1 % n2);
    }

    public static long factorial(long a) {
        return a == 0 || a == 1 ? 1 : a * factorial(a - 1);
    }

    public static void sort(int arr[]) {
        shuffle(arr);
        Arrays.sort(arr);
    }

    public static void shuffle(int arr[]) {
        Random rnd = new Random();
        for (int i = arr.length - 1; i > 0; i--) {
            int index = rnd.nextInt(i + 1);
            int temp = arr[index];
            arr[index] = arr[i];
            arr[i] = temp;
        }
    }

    public static Double[] solveQuadratic(double a, double b, double c) {
        double result = (b * b) - 4.0 * a * c;
        double r1;
        if (result > 0.0) {
            r1 = ((double) (-b) + Math.pow(result, 0.5)) / (2.0 * a);
            double r2 = ((double) (-b) - Math.pow(result, 0.5)) / (2.0 * a);
            return new Double[]{r1, r2};
        } else if (result == 0.0) {
            r1 = (double) (-b) / (2.0 * a);
            return new Double[]{r1, r1};
        } else {
            return new Double[]{null, null};
        }
    }

    public static BigDecimal[] solveQuadraticBigDecimal(double aa, double bb, double cc) {
        BigDecimal a = BigDecimal.valueOf(aa), b = BigDecimal.valueOf(bb), c = BigDecimal.valueOf(cc);
        BigDecimal result = (b.multiply(b)).multiply(BigDecimal.valueOf(4).multiply(a.multiply(c)));
        BigDecimal r1;
        if (result.compareTo(BigDecimal.ZERO) > 0) {
            r1 = (b.negate().add(bigSqrt(result)).divide(a.multiply(BigDecimal.valueOf(2))));
            BigDecimal r2 = (b.negate().subtract(bigSqrt(result)).divide(a.multiply(BigDecimal.valueOf(2))));
            return new BigDecimal[]{r1, r2};
        } else if (result.compareTo(BigDecimal.ZERO) == 0) {
            r1 = b.negate().divide(a.multiply(BigDecimal.valueOf(2)));
            return new BigDecimal[]{r1, r1};
        } else {
            return new BigDecimal[]{null, null};
        }
    }

    private static BigDecimal sqrtNewtonRaphson(BigDecimal c, BigDecimal xn, BigDecimal precision) {
        BigDecimal fx = xn.pow(2).add(c.negate());
        BigDecimal fpx = xn.multiply(new BigDecimal(2));
        BigDecimal xn1 = fx.divide(fpx, 2 * BigDecimal.valueOf(16).intValue(), RoundingMode.HALF_DOWN);
        xn1 = xn.add(xn1.negate());
        BigDecimal currentSquare = xn1.pow(2);
        BigDecimal currentPrecision = currentSquare.subtract(c);
        currentPrecision = currentPrecision.abs();
        if (currentPrecision.compareTo(precision) <= -1) {
            return xn1;
        }
        return sqrtNewtonRaphson(c, xn1, precision);
    }

    public static BigDecimal bigSqrt(BigDecimal c) {
        return sqrtNewtonRaphson(c, new BigDecimal(1), new BigDecimal(1).divide(BigDecimal.valueOf(10).pow(16)));
    }

    static class graph {
        int V;
        ArrayList<Integer> adjL[];
        boolean vis[];

        public graph(int V) {
            this.V = V;
            adjL = new ArrayList[V + 1];
            vis = new boolean[V + 1];
            for (int i = 0; i < V + 1; i++) adjL[i] = new ArrayList<>();
        }

        public void addEdge(int v1, int v2) {
            this.adjL[v1].add(v2);
        }

        public void BFS(int n) {
            Queue<Integer> q = new LinkedList<>();
            q.add(n);
            while (!q.isEmpty()) {
                int a = q.poll();
                vis[a] = true;
                for (int x : adjL[a]) {
                    if (!vis[x]) {
                        vis[x] = true;
                        q.add(x);
                    }
                }
            }
        }

        public void DFS(int v) {
            vis[v] = true;
            for (int u : adjL[v]) {
                if (!vis[u]) {
                    DFS(u);
                }
            }
        }

        public void DFS(int v, Stack<Integer> st) {
            vis[v] = true;
            for (int u : adjL[v]) {
                if (!vis[u]) {
                    DFS(u, st);
                }
            }
            st.push(v);
        }
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }

    static class pair<E1, E2> implements Comparable<pair> {
        E1 x;
        E2 y;

        pair(E1 x, E2 y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public int compareTo(pair o) {
            return x.equals(o.x) ? (Integer) y - (Integer) o.y : (Integer) x - (Integer) o.x;
        }

        @Override
        public String toString() {
            return x + " " + y;
        }

        public double pointDis(pair p1) {
            return Math.sqrt(((Integer) y - (Integer) p1.y) * ((Integer) y - (Integer) p1.y) + ((Integer) x - (Integer) p1.x) * ((Integer) x - (Integer) p1.x));
        }
    }

}

import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long ans = n;
		long i = 1;
        while(n>0){
            ans =n;
            n -=i;
            i++;
        }
        System.out.println(ans);
	}
}

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner s=new Scanner(System.in);
long n=s.nextLong();
long som=1;
long i=1;
if (n==1) System.out.print(n);
else{
while(true){
	i++;
	if ((n-som-i)<=0) break;
	som+=i;
}
System.out.print(n-som);
}
	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author P Marecki
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long X = in.nextLong();
            long L = 0, R = (long) (2e7);    //sumL<=X
            while (R - L > 1) {
                long M = (R + L) / 2;
                if (M * (M + 1) / 2 < X) {
                    L = M;
                } else R = M;
            }
            out.println(X - L * (L + 1) / 2);

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

import java.util.Scanner;

/**
 *
 * @author toshiba
 */
public class Test1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long l = in.nextLong();

        for (int i = 1; i < l; i++) {
            l -= i ;
        }
        System.out.println(l);
    }

}

import java.util.*;

public class InfiniteSequence
{
	public static void main(String args[])
	{
		long n;
		Scanner s=new Scanner(System.in);
		n=s.nextLong();
		long i=1;
		while(n-i>0)
		{
			n=n-i;
			i++;
		}
		System.out.print(n);
	}
}

import java.util.Scanner;

/**
 *
 * @author AdminHP-262
 */
public class InfiniteSequence {

    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);

        long n = scanner.nextLong();

        long sum = 0, oldSum = 0;
        for (long i = 1; ; i++) {

            sum += i;

            if (sum == n) {
                System.out.println(i);
                return;
            }
            if (sum > n) {
                System.out.println(n - oldSum);
                return;
            }
            oldSum = sum;
        }
    }
}

import java.util.Scanner;
public class InfiniteSequence {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        long n = input.nextLong();
        for (long i = 0; n-i>0 ; i++) {
            n = n-i;
        }
        System.out.println(n);
    }
}

import java.io.*;

public class Infinite {
	public static void main(String args[]) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s0 = br.readLine();
        double n = (double)Long.parseLong(s0);
        long sum =0;
        long i =0;
        while(sum < n)
        {
        	i++;
        	sum = sum+i;

        }
        System.out.println((int)(n-(sum-i)));
	}
}

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long x = in.nextLong();
        long i = 1;
        while(x > 0){
            x -= i;
            i++;
        }
        System.out.println(x += --i);

    }
}

import java.util.Scanner;

/**
 * Created by soumen.porel on 02/07/17.
 */
public class InfiniteSequence {

    public static void main(String[] atgs){

        Scanner scanner = new Scanner(System.in);
        long num = scanner.nextLong();
        long n = num;
        long j=1;

        for (int i=1; n > 0;i++){
            j = n;
            n -= i;
        }

        System.out.print(j);
    }
}

        import java.awt.*;
        import java.io.*;
        import java.math.BigInteger;
        import java.util.*;

public class A {

    FastScanner in;
    PrintWriter out;

    public void solve() throws IOException {

        long n = in.nextLong();

        for (long i = 1; n > i; i++) {
            n -= i;
        }
        out.print(n);

    }

    public void run() {
        try {
            //in  = new FastScanner(new File("search.in"));
            //out = new PrintWriter(new File("search.out"));

            in = new FastScanner();
            out = new PrintWriter(System.out);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        String nextLine() {
            String ret = null;
            try {
                ret = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return ret;
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int size) {
            int[] array = new int[size];

            for (int i = 0; i < size; i++) {
                array[i] = nextInt();
            }

            return array;
        }

        long[] nextLongArray(int size) {
            long[] array = new long[size];

            for (int i = 0; i < size; i++) {
                array[i] = nextLong();
            }

            return array;
        }

        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }

        Point nextIntPoint() {
            int x = nextInt();
            int y = nextInt();
            return new Point(x, y);
        }

        Point[] nextIntPointArray(int size) {
            Point[] array = new Point[size];

            for (int index = 0; index < size; ++index) {
                array[index] = nextIntPoint();
            }

            return array;
        }

        java.util.List<Integer>[] readGraph(int vertexNumber, int edgeNumber, boolean undirected) {
            java.util.List<Integer>[] graph = new java.util.List[vertexNumber];

            for (int index = 0; index < vertexNumber; ++index) {
                graph[index] = new ArrayList<Integer>();
            }

            while (edgeNumber-- > 0) {
                int from = nextInt() - 1;
                int to = nextInt() - 1;

                graph[from].add(to);

                if (undirected)
                    graph[to].add(from);
            }

            return graph;
        }
    }

    public static void main(String[] arg) {
        new A().run();
    }
}

import java.util.Scanner;
public class Slime
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		int	k=1;
		while (n>k)
		{
			n-=k;
			k+=1;
		}
		System.out.println(n);
	}

}

//package solution;

import java.io.*;
import java.util.*;
import java.awt.Point;
import java.math.BigInteger;

public final class Solution {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Solution().run();
    }

    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    void run() throws Exception {
        long n = nl(), ptr = 1;
        while(true) {
            if(n - ptr <= 0)
                break;
            n -= ptr;
            ptr++;
        }
        pl(n);
    }

    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

    int ni() throws Exception {
        return Integer.parseInt(nextToken());
    }

    long nl() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nd() throws Exception {
        return Double.parseDouble(nextToken());
    }

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }

    //1 10 30 15 30 60 20
    //2 10 30 15 30 60 20 2 4 7 11 21 36
    //1 5 8 9 700 1000 1100
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Nguyen Trung Hieu - vuondenthanhcong11@gmail.com
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            long count = in.readLong();

            for (long i = 0; i < 20000000; i++) {
                if (i * (i + 1) / 2 >= count) {
                    count -= i * (i - 1) / 2;
                    break;
                }
            }

            out.printLine(count);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(long i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

/* IMPORTANT: Multiple classes and nested static classes are supported */

/*
 * uncomment this if you want to read input.
//imports for BufferedReader*/
import java.io.*;
import java.io.InputStreamReader;
import java.util.Vector;

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

   public class TestClassFinalA {

	   public static void main(String args[] ) throws Exception {

    	BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));

        long n;
        n=Long.parseLong(sc.readLine());

       int i=1;
       long aux=0;
       int nbsous=0;
        while (n>0)
        {
        	aux=n;
        	n=n-i;
        	i++;
        	nbsous++;

        }
        //System.out.println(nbsous);
        System.out.println(aux);
        for(i=1;i<=nbsous;i++)
        	if (i==aux)
        	{
        		//System.out.prin
        	}

        /*Non optimal solution it cause time limit exceeded
         * Vector <Long> v=new Vector<Long>();
        for(int i=1;i<=n;i++)
        	for(int j=1;j<=i;j++)
        	{
        		v.add(new Long(j));
        		if (v.size()==n)
        		{
        			System.out.println(j);
        			return;
        		}

        	}*/
sc.close();
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            long n = in.nextLong();
            long low = 0;
            long high = 14142136;
            while (high - low > 1)
            {
                long mid = low + (high - low) / 2;
                long last = mid * (mid + 1);
                last /= 2;
                if (last <= n)
                {
                    low = mid;
                } else
                {
                    high = mid;
                }
            }
            long last = low * (low + 1);
            last /= 2;
            if (last == n)
            {
                out.println(low);
                return;
            }
            out.println(n - last);
//

//        long low = -1;
//        long high = ((long) 1e9);
//        while (high - low > 1)
//        {
//            long mid = low + (high - low) / 2;
//            long last = mid * (mid + 1);
//            last /= 2;
//            if (last <= 1e14)
//            {
//                low = mid;
//            } else
//            {
//                high = mid;
//            }
//        }
//        System.out.println("MAX = " + low + " max value = " + (low * (low + 1)) / 2);
//        low = low + 1;
//        System.out.println((low * (low + 1)) / 2);
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

        public String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                String s = null;
                try
                {
                    s = br.readLine();
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

    }
}

import java.util.Scanner;

public class InfiniteSequence {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n=in.nextLong();
        long r=1;
        long i=2;
    if(n==1)
        System.out.println(1);
    else{
            for( ; ; i++){
                r= r+i;
                if(r>=n)
                    break;
            }
            while(r>n){
                i--;
                r--;
            }
            System.out.println(i);
        }
    }
}

import java.util.*;
import java.io.*;
public class a {
	public static void main(String[] args) throws IOException {
		in.init(System.in);
		PrintWriter out = new PrintWriter(System.out);

		long n = in.nextLong();
		long hi = 1000000000l;
		long lo = 0l;
		while(hi-lo>1)
		{
			long mid = (hi+lo)/2;
			long check = (mid*(mid+1))/2l;
			if(check >= n)
				hi = mid;
			if(check < n)
				lo = mid;
		}
		hi--;
		long at = (hi*(hi+1))/2;
//		System.out.println(hi+" " + lo + " "+ at);
		long ans = n - at;
		out.println(ans);
		out.close();
	}

	public static class in {
		static BufferedReader reader;
		static StringTokenizer tokenizer;

		static void init(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = new StringTokenizer("");
		}

		static String next() throws IOException {
			while (!tokenizer.hasMoreTokens()) {
				tokenizer = new StringTokenizer(reader.readLine());
			}
			return tokenizer.nextToken();
		}

		static int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		static double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		static long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}

import java.util.Scanner;

public class sequence_inf {

	static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		long n = scanner.nextLong();
		System.out.println(seq(n));

	}

	static long seq(long n) {

		if(n == 1)
			return 1;

		for(int i = 1; i < n; ++i)
			n -= i;

		return n;
	}

}

import java.util.Scanner;

public class A {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		long x= sc.nextLong();
		long n=0L;
		long result;

		long i;
		for(i=1L; i<=x; i++){
			if((i*(i+1))/2>=x){
				n= (i*(i+1))/2;
				break;
			}
		}
		result=i-(n-x);

		System.out.println(result);
	}

}

import java.util.Scanner;

public class TaskA {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		long idx = in.nextLong();
		long n = 0;
		while(idx > 0) {
			n++;
			idx -= n;
		}
		System.out.println(n+idx);
	}
}

import java.util.Scanner;

public class InfiniteSquence {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long positionOfOne = 1;
		long increment = 0;
		while(positionOfOne <= n){
			increment += 1;
			positionOfOne +=increment;
		}
		positionOfOne -=increment;
		long result = 1;
		while(positionOfOne != n){
			result++;
			positionOfOne++;
		}
		System.out.println(result);
	}
}

import java.util.*;

public class A {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int tc = 1;
        for(int i = 0; i < tc; i++) {
            tc();
        }
    }

    private static void tc() {
        long n = sc.nextLong()-1;
        long k = 0;
        while(k*(k+1)/2 <= n) {
            k++;
        }
        k--;
        System.out.println(n - k*(k+1)/2 + 1);
//        throw null;
    }

    private static int[] readArray(int n) {
        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        return a;
    }
}

import java.io.*;    //PrintWriter
import java.math.*;  //BigInteger, BigDecimal
import java.util.*;  //StringTokenizer, ArrayList

public class R342_Ed7_A
{
	FastReader in;
	PrintWriter out;

	public static void main(String[] args)  {
		new R342_Ed7_A().run();
	}

	void run()
	{
		in = new FastReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	void solve()
	{
		long n = in.nextLong();

		long i = 1;
		while (i*(i+1) / 2 < n) i++;
		i--;
		long ans = n - i * (i+1) / 2;

		out.println(ans);
	}

	//-----------------------------------------------------
	void runWithFiles() {
		in = new FastReader(new File("input.txt"));
		try {
			out = new PrintWriter(new File("output.txt"));
		}
		catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		solve();
		out.close();
	}

	class FastReader
	{
	    BufferedReader br;
	    StringTokenizer tokenizer;

	    public FastReader(InputStream stream)
	    {
	        br = new BufferedReader(new InputStreamReader(stream));
	        tokenizer = null;
	    }
		public FastReader(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
				tokenizer = null;
			}
			catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

	    private String next() {
	        while (tokenizer == null || !tokenizer.hasMoreTokens())
	            try {
	            	tokenizer = new StringTokenizer(br.readLine());
	            }
	            catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        return tokenizer.nextToken();
	    }
		public String nextLine() {
			try	{
				return br.readLine();
			}
			catch(Exception e) {
				throw(new RuntimeException());
			}
		}

	    int nextInt() {
	        return Integer.parseInt(next());
	    }
	    long nextLong() {
	        return Long.parseLong(next());
	    }
	    double nextDouble() {
	        return Double.parseDouble(next());
	    }
	    BigInteger nextBigInteger() {
	        return new BigInteger(next());
	    }
	    BigDecimal nextBigDecimal() {
	        return new BigDecimal(next());
	    }
	}
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.Scanner;

/**
 *
 * @author yashvi1902
 */
public class infiniteSequence {
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       long n = sc.nextLong();
      for(int i=0;;i++){
          if(i<n){
              n = n-i;
          }
          else{
              System.out.println(n);
              break;
          }
      }

    }
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class npattern {
 static Scanner std = new Scanner(System.in);

    public static int nextInt(){
    	return std.nextInt();
    }

    public static long nextLong(){
    	return std.nextLong();
    }

    public static String next(){
    	return std.next();
    }

    public static String nextLine(){
    	return std.nextLine();
    }

    public static int[] nextArr(int n){
        int[] arr = new int[n];
        for(int i=0;i<n;i++){
            arr[i] = nextInt();
        }
        return arr;
    }

    public static long fact(int n){
        if(n==1) return 1;
        return n*fact(n-1);
    }

    public static void printArray(int[] arr, int n ){
    	for(int i=0;i<n;i++) System.out.print(arr[i]+" ");
    	System.out.println();
    }

    public static void printArray2(int[][] arr, int n, int m){
    	for(int i=0;i<n;i++) for(int j=0;j<m;j++) System.out.print(arr[i][j]+" "); System.out.println();
    }

    public static void print(String str){
        System.out.print(""+str+" ");
    }

    public static void println(String str){
        System.out.println(""+str);
    }

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        long n = nextLong();
        long i =0;
        long last=0;
        while(true){
            if(n -(i*(i+1)/2) > 0){
			last = n -(i*(i+1)/2);
		}
		else
		{
			println(""+last);
			break;
		}
		i++;
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CF_622A solver = new CF_622A();
        solver.solve(1, in, out);
        out.close();
    }

    static class CF_622A {
        public void solve(int testNumber, InputReader input, PrintWriter out) {
            FastScanner in = new FastScanner(input);
            long n = in.l();

            long bound = sqrt(n * 2);
            long left = bound * (bound + 1) / 2;
            while (left >= n) {
                bound--;
                left = bound * (bound + 1) / 2;
            }
            long idx = n - left;
            out.println(idx);
        }

        long sqrt(long x) {
            long rs = (long) Math.sqrt(x);
            while (rs * rs < x)
                rs++;
            while (rs * rs > x)
                rs--;
            return rs;
        }

    }

    static class FastScanner {
        InputReader in;

        public FastScanner(InputReader in) {
            this.in = in;
        }

        public long l() {
            return in.nextLong();
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

import java.io.*;
import java.lang.reflect.Array;
import java.nio.Buffer;
import java.util.*;

public class Pair {

    public static void main(String[] args) throws Exception {
        try {
            Scanner sc = new Scanner(System.in);
            long n = sc.nextLong();
            int i;
            for( i=1;n>=1;i++){
                n-=i;
            }
            System.out.println(n+i-1);
        }
        catch (Exception e) {
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class KSN {

	static PrintWriter out = new PrintWriter(System.out);

	static void input() throws IOException {
		Reader.init(System.in);
	}

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub

		input();
		solve();
	}

	static void solve() throws IOException {

		long n = Reader.nextLong();
		/*
		 * long low = 0; long high = 100000000; long re = 0; while (low <= high)
		 * { long mid = (low + high) / 2; if (mid * (mid + 1) / 2 < n) { re =
		 * mid; low = mid + 1; } else { high = mid - 1; } } out.println(n - (re
		 * * (re + 1) / 2));
		 */

		long temp = n;
		int i = 0;

		while (temp > 0) {
			i++;
			temp -= i;
		}

		out.println(i + temp);

		out.flush();
		out.close();
		////////////////////// No Business TO DO HERE... Up Up ^^^

	}

	static class Reader {

		static BufferedReader reader;
		static StringTokenizer tokenizer;

		static void init(InputStream input) {
			reader = new BufferedReader(new InputStreamReader(input));
			tokenizer = new StringTokenizer("");
		}

		static String next() throws IOException {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {

				tokenizer = new StringTokenizer(reader.readLine());
			}
			return tokenizer.nextToken();
		}

		static String nextLine() throws IOException {
			return reader.readLine();
		}

		static char nextChar() throws IOException {
			return (char) reader.read();
		}

		static int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		static double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		static long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		static long[] nextLongArray(int n) throws IOException {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLong();
			}

			return arr;
		}

		static int[] nextIntArray(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

	}

}

import java.io.*;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import static java.lang.Math.*;

public class ballov100 {
    public static void main(String [] args) throws FileNotFoundException {

        MyScanner cin = new MyScanner(System.in);
        PrintWriter cout = new PrintWriter(System.out);

        long n = cin.nextLong();
        long cc = 1;

        while (n - cc > 0) {
            n -= cc; cc++;
        }
        cout.print(n);
        cout.close();
    }
}

class MyScanner {
    BufferedReader br;
    StringTokenizer st;
    public MyScanner(FileReader in){
        br = new BufferedReader(in);
    }
    public MyScanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(in));
    }

    String next(){
        while(st == null || !st.hasMoreElements()){
            try{
                st = new StringTokenizer(br.readLine());
            } catch (IOException e){
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    String tmp = "";
    int nextInt(){return Integer.parseInt(next());}
    double nextDouble(){return Double.parseDouble(next());}
    long nextLong(){return Long.parseLong(next());}

    String nextLine(){
        String str = "";
        try{
            str = br.readLine();
        } catch (IOException e){
            e.printStackTrace();
        }
        return str;
    }
}

import java.util.Scanner;

public class competitive24 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        long n= in.nextLong();
        long k=0,i;
        for(i=1;i<1000000000;i++){
            if(((i*(i+1))/2)<=n && (((i+1)*(i+2))/2)>n){
              if(((i*(i+1))/2)==n){
                  k=i;
                  break;
              }
              else {
                  k = (i+1)-((((i+2)*(i+1)) / 2) % n);
                  break;
              }
            }
        }
        System.out.println(k);
    }
}

import java.util.Scanner;

public class AEdu7 {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		long n = s.nextLong();
		long skipC = 0, num = 1;
		while(skipC < n) {
			skipC+=num;

			num++;
		}
		System.out.println((num-1) - (skipC-n) );
	}
}

import java.io.*;
import java.util.*;
/**
 *
 * @author Aaryan
 * AV
 */
public class Test {
    public static void main(String[] args) throws Exception {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        long n = Long.parseLong(br.readLine());
        long res=1;

        while((Math.pow(res, 2)+res)/2<n){
            res++;
        }
        res--;
        if((Math.pow(res, 2)+res)/2==n){
            out.println(res);
            out.flush();
        }
        else{
            out.println(n-(long)(Math.pow(res, 2)+res)/2);
            out.flush();
        }

        }
    }

import java.util.*;
import java.math.*;
import java.io.*;
import java.text.*;

public class practice {
    public static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    public static int mod(int a, int b, int m) {
        if (b == 0) {
            return 1;
        } else if (b == 1) {
            return a % m;
        } else {
            if (b % 2 == 0) {
                return ((mod(a, b / 2, m) % m) * (mod(a, b / 2, m)) % m) % m;
            } else {
                return (a * ((mod(a, b / 2, m) % m) * (mod(a, b / 2, m)) % m)) % m;
            }
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long a = Long.parseLong(br.readLine());
        long n = a;
        n--;
        for (long i = 1; i <= n; i++) {
            n -= i;
        }
        System.out.println(n+1);
    }
}

class sort implements Comparator<ArrayList<Long>> {

    @Override
    public int compare(ArrayList<Long> o1, ArrayList<Long> o2) {
        int c = o1.get(2).compareTo(o2.get(2));
        return c;
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

    public class Training {

            public static void main(String[] args) throws IOException {
 		Scanner input = new Scanner(System.in);
                long n= input.nextLong();
               long d = 1;
        while(n > d){
            n -= d;
            d++;
        }
        System.out.println(n);

        } // end Main

    } // end Class

import java.util.Scanner;

public class InfiniteSequence {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();

		long d = (int) Math.sqrt(1 + 8 * n);
		long x = (-1 + d) / 2;
		long ans = (x * (x + 1)) / 2;
		if (ans == n) {
			System.out.print(x);
		} else {
			System.out.println(n - ans);
		}
		sc.close();
	}
}

import java.util.Scanner;

public class Main {
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        long num = in.nextLong();
        long m = 1;
        while(num - m > 0)
        {
            num -= m;
            ++m;
        }
        System.out.print(num);
    }
}

import java.awt.*;
import java.io.InputStream;
import java.lang.reflect.Array;
import java.util.*;

public class HelloWorld {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        if(n==1)
            System.out.print(1);
        else {
            long i = 2;
            long max_l = 1;
            long max_i = 1;
            while (max_i < n)
            {
                max_i+=i;
                if(max_i<n)
                    max_l=max_i;
                i++;
            }
            System.out.print(n-max_l);
        }

    }

}

import java.io.*;
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        long n = sc.nextLong();

        long group = 1;
        while(group < n) {
        	n -= group;
        	group++;
        }

        // out.println(group);
        out.println(n);
        // Start writing your solution here.

        /*
        int n      = sc.nextInt();        // read input as integer
        long k     = sc.nextLong();       // read input as long
        double d   = sc.nextDouble();     // read input as double
        String str = sc.next();           // read input as String
        String s   = sc.nextLine();       // read whole line as String

    	while(sc.hasNext()) {
    		...
    	}

        int result = 3*n;
        out.println(result);                    // print via PrintWriter
        */

        // Stop writing your solution here.
        out.close();
    }

    // PrintWriter for faster output
    public static PrintWriter out;

    // MyScanner class for faster input
    public static class MyScanner
    {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        boolean hasNext()
        {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    return false;
                }
            }
            return true;
        }

        String next()
        {
            if (hasNext())
                return st.nextToken();
            return null;
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.io.*;
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        long n = sc.nextLong();

        long group = 1;
        while(group < n) {
        	n -= group;
        	group++;
        }

        // out.println(group);
        out.println(n);

        // Stop writing your solution here.
        out.close();
    }

    // PrintWriter for faster output
    public static PrintWriter out;

    // MyScanner class for faster input
    public static class MyScanner
    {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        boolean hasNext()
        {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    return false;
                }
            }
            return true;
        }

        String next()
        {
            if (hasNext())
                return st.nextToken();
            return null;
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class test {

    public static void main(String[] args)throws IOException {
    	Scanner ob=new Scanner(System.in);
    	long n=ob.nextLong();
    	long i=1,x=0;
    	while(true)
    	{
    		if(x+i<n)
    		{
    		x+=i;
    		i++;
    		}
    		else break;
    	}
       	System.out.println(n-x);
 	 }

 }

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();

            long temp = 1;
            long prev = 0;
            for (long i = 1; temp <= n; i++) {
                prev = temp;
                temp = i + temp;
            }

            out.println(n - prev + 1);

        }

    }
}

import java.io.*;

public class A {
  public static void main(String[] args) throws Exception {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long n = Long.valueOf(reader.readLine());
    long num = n;
    long count = 1;
    while ((num - count) > 0) {
      num -= count;
      count += 1;
    }
    if (num == 0) System.out.print(count - 1);
    else System.out.print(num);
  }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Van Hanh Pham <skyvn97> <vanhanh.pham@gmail.com>
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            int cnt = 0;
            while (1L * cnt * (cnt + 1) / 2 < n) cnt++;
            out.println(n - 1L * cnt * (cnt - 1) / 2);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String nextString() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(nextString());
        }

    }
}

import javax.management.timer.Timer;
import java.sql.Time;
import java.util.Scanner;

/**
 * Created by xgh on 2016/2/16.
 */
public class CF{
        public static void main(String[] args){
            Scanner in=new Scanner(System.in);
            long  a=in.nextLong();
            //long a=1000000000000L;
            long a_one=count(a);

            //System.out.println(a_one);

            if(a_one*a_one+a_one==2*a){
                System.out.println(a_one);
            }else{
                long tmp=(long)a-(a_one*a_one+a_one)/2;
                System.out.println(tmp);
            }
            return;
        }

        public static long count(long  num) {
            long num_two = 2 * num;
            long i = (long) Math.sqrt(num_two) - 1;
            //System.out.println(i);
            if (i < 0) {
                i = 0;
            }
            for (; i <= num; i++) {
                //System.out.println(i);
                if (i * i + i == num_two) {
                    return i;
                }
                if (i * i + i > num_two) {
                    return i - 1;
                }
            }
            return 0;
        }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Junior Andrade
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            long x = in.nextLong();
            x--;

            long lo = 0, hi = 10000000000L;
            while (lo < hi) {
                long mid = (lo + hi + 1L) >> 1L;
                if (((mid + 1L) * mid) / 2L <= x) lo = mid;
                else hi = mid - 1;
            }
            x -= ((lo + 1L) * lo) / 2L;

            for (int i = 1; ; i++) {
                if (x == 0) {
                    out.printLine(i);
                    break;
                }
                x--;
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(int i) {
            writer.println(i);
        }

    }
}

//package com.codeforces.div2.A;

import java.io.*;
import java.util.InputMismatchException;

public class InfiniteSequence {

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);

        long N = in.readLong();
        N = N - 1;

        for (long i = 1; i <= N; ++i) {
            N = N - i;
        }

        out.print(N + 1);
        out.close();
    }

    //FAST IO
    private static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1 << 10];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public double readDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, readInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            boolean isSpaceChar(int ch);
        }
    }

    private static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }

    }
}

import java.util.*;

public class InfiniteSequence {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    long input = sc.nextLong();

    long count = 1;
    long maxSol = 1;

    while(maxSol < input) {
      count++;
      maxSol = ( count * ( count + 1 ) ) / 2;
    }

    if(maxSol == input) {
      System.out.println(count);
    } else {
      long diff = maxSol - input;
      count -= diff;
      System.out.println(count);
    }

    sc.close();
  }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Infinite {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader in;
		File f = new File("entrada.txt");
		if (f.exists()) {
			in = new BufferedReader(new FileReader(f));
		} else {
			in = new BufferedReader(new InputStreamReader(System.in));
		}

		long n = Long.parseLong(in.readLine());
		long cont = 2;
		long r = 1;
		while (r < n) {
			r = r + cont;
			cont++;
		}
		cont--;
		System.out.println(cont - (r - n));
	}
}

import java.util.*;

public class A{
    public static void main( String[] args){
        Scanner in = new Scanner(System.in);
        long n  = in.nextLong();
		long i = 1;
while(i*(i+1)/2<n){
i++;
}
        System.out.println(i-i*(i+1)/2+n);
    }
}

import java.util.Scanner;

public class InfiniteSequence {
	public static long calculate(long n) {
		long count = 1;
		while (n > count) {
			n -= count;
			count++;
		}
		return n;
	}

	public static void main(String[] args) {
		Scanner user = new Scanner(System.in);
		long n = Long.parseLong(user.next());
		user.close();
		System.out.println(calculate(n));
	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class InfSequence {

	static long N;
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[]args)throws Throwable
	{
		N = Long.parseLong(br.readLine());
		int pos = 0;
		for(long i = 1;true;i++)
		{
			if(N <= 0)
			{
				System.out.println((i-1)+N);
				break;
			}
			N -= i;

			pos += i;
		}
	}
}

import java.util.Scanner;

public class InfSeq {

	public static long func(long n) {
		n -= 1;
		for (long i = 1; i <= n; ++i) n -= i;
		return n + 1;
	}

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long n = input.nextLong();
		System.out.println(func(n));
	}
}

import java.util.*;
import java.io.*;
public class Main {
public static void main(String [] args)throws Exception{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	long n = Long.parseLong(br.readLine());

	long low = 0;
	long high = (long)1E9;
	while(low < high){
		long mid = (low + high)/2;
		if(mid*(mid + 1)/2 < n)
			low = mid + 1;
		else high = mid;
	}
	--high;
//	System.out.println(high);
	System.out.println(n - (high)*(high + 1)/2);
}
}

import java.util.Scanner;

/**
 * Created by Admin on 06.03.2016.
 */
public class Main {

    Main(long n){

        int c = 0;
        long t = n;

        while (t > 0){

            t-=(c+1);
            c++;

        }

        System.out.print(c + t);

    }

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        Main obj = new Main(n);

    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new PrintWriter(System.out));

        long n = Long.parseLong(br.readLine());

        //find pos for n

        int lo = 1;
        int hi = 1000000000;

        while(lo < hi){
            int mid = lo + (hi-lo+1)/2;
            long sum = 1L*(mid+1)*(mid);
            sum/=2;

            long ssum = 1L*(mid)*(mid-1);
            ssum/=2;

            ssum+=1;

            //System.out.println(ssum+" "+sum+" "+mid);
            if(ssum > n){
                hi = mid-1;
            }else{
                lo = mid;
            }
        }

       // System.out.println(lo+" -");

        long sum = 1L*lo*(lo-1);
        sum/=2;

        System.out.println(n-sum);

        bw.close();

    }

}

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Stack;

public class Main
{
	static Scanner in = new Scanner(System.in);
	static long N = (long) (2*1e14);
	static long ed = 14142136;
	public static void main(String[] args)
	{
		long pos = in.nextLong();
		N = 2*pos;
		long index = binary_search(1, ed, N);
		;
		long left = N - mul(index);
		left /=2;
		//System.out.println(index+" "+left);
		System.out.println(left==0?index:left);

	}
	static long binary_search(long st, long ed, long N)
	{
		long mid = (st+ed)>>1;
		if(mul(mid)<=N && mul(mid+1)>N)
			return mid;
		if(mul(mid)>N)
		{
			return binary_search(st, mid, N);
		}
		else
			return binary_search(mid, ed, N);

	}
	static long mul(long x)
	{
		return x*x+x;
	}
}

import java.util.Scanner;

public class Tester {
	public static void main(String args[]){
		Scanner s1=new Scanner(System.in);
		long num=s1.nextLong();
		num--;
		long i=1;
		while(i<=num)
		{
			num=num-i;
			i++;
		}
		System.out.println(num+1);
	}
}

import java.util.Scanner;

public class su {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
	long n=sc.nextLong();
	long x=(long)((-1+Math.sqrt(1+8*n))/2);
	long j=n-(x*(x+1))/2;
		if(j==0)
			j=x;
		System.out.println(j);

	}
}

import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = 1;long i = 0;
		for(i = 1;i<n;i+=k)k++;
		System.out.println(k-(i-n));
	}
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

import java.util.Set;
import java.util.Map.Entry;

import java.util.HashMap;
import java.util.Iterator;

public class test {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        Long n = input.nextLong();
        Long result = n;
        Long count = 1L;
        while(n - count > 0){
            n -= count;
            //System.out.println("n = " +n + " count =" +count);
            count++;
        }
        count--;
        Long temp = (1+count)*count /2;
        //System.out.println(temp);
        System.out.println(result - temp);

    }
}

import java.io.*;

public class A {
  public static void main(String[] args) throws Exception {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long n = Long.valueOf(reader.readLine());
    long num = n;
    long count = 1;
    while (num > 0 && n >= num) {
      num -= count;
      count += 1;
    }
    System.out.print(count - 1);
  }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class a {

	public static void main(String []args){
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		long k=1;
		for(long i=1;i<=n;i++ ){
			k+=i;
			if(k>=n){
				System.out.println((n%(k-i))+1);
				break;
			}
		}
	}

}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class a {

	public static void main(String []args){
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		long k=0;
		if(n==1){
			System.out.println(1);
		}
		if(n==2){
			System.out.println(1);
		}
		if(n==3){
			System.out.println(2);
		}
		if(n==4){
			System.out.println(1);
		}
		if(n==6){
			System.out.println(3);
		}
		else{
		for(long i=1;i<=n;i++ ){
			k+=i;
			if(k>=n){
				System.out.println((n%(k-i)));
				break;
			}
		}
		}
	}

}

import java.util.Scanner;

/**
 *
 * @author Ahmed
 */
public class InfiniteSequence {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong();
        /*ArrayList<Long> value = new ArrayList<>();
        long inc = 0;
        for(long i=0;i<n+1;){
            i+=inc;
            value.add(i);
            inc++;
        }
        int res = (int) (n - value.get(value.size()-2));
        if(res == 0)
        {
            res = value.indexOf(n);
        }
        System.out.println(res + " " + value.size());*/
        int res = 0;
        int x = (int) Math.round(Math.sqrt(n*2));
        if((x*(x-1)/2) == n)
            res = x;
        else
            res = (int) (n- (x*(x-1)/2));
//        if(res <= 0)
//            res += x;
        System.out.println(res);
    }
}

import java.util.Scanner;

public class A {
    public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            long n = scanner.nextLong();

            int x = Double.valueOf((Math.sqrt(8.0 * n + 1) - 1) / 2).intValue();

            System.out.println(n - ((x * (x + 1)) / 2));
        }

}

import java.util.*;
import java.io.*;
public class Main {
public static void main(String [] args)throws Exception{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	long n = Long.parseLong(br.readLine());

	long low = 0;
	long high = 1000_0010;
	while(low < high){
		long mid = (low + high)/2;
		if(mid*(mid + 1)/2 < n)
			low = mid + 1;
		else high = mid;
	}
	--high;
	System.out.println(n - (high)*(high + 1)/2);
}
}

import java.util.Scanner;

public class infsequ {
	public static void main(String[] args){
		long n;
		Scanner enter = new Scanner(System.in);
		n = enter.nextLong();
		long equ=n;
		for (long i=1; i<n;i++){
			if (equ<=i){
				System.out.println(equ);
				break;
			}
			equ=equ-i;
		}
	}

}

import java.util.Scanner;

public class infsequ {
	public static void main(String[] args){
		long n;
		Scanner enter = new Scanner(System.in);
		n = enter.nextLong();
		long equ=n;
		for (long i=1; i<n;i++){
			System.out.println(n+"      "+i+"    "+equ);
			if (equ<=i){
				System.out.println(equ);
				break;
			}
			equ=equ-i;
		}
	}

}

import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long k = 1;
		for(long i = 1;i<n;i+=k)k++;
		System.out.println(k);
	}
}

import java.util.Scanner;
public class InfiniteSequence {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();

		long ans = (long) Math.sqrt(n * 2);
		long sum = ans * (ans + 1) / 2;
		System.out.println(ans - (sum - n));
		/*long x = 0;
		long sum = 0;

		while (sum < n) {
			x++;
			sum = sum + x;
		}
		System.out.println(x - (sum-n));*/
	}
}

//package sample;

import java.util.Scanner;

public class main {
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		long x=(-1+(long)Math.sqrt(1+(4*n*2)))/2;
		//System.out.println(x);
		long ans=(x*(x+1))/2;
		System.out.println(n-ans);
	}
}

import java.util.*;

public class Infinite{

	public static long infinite(long n, int i, long[] list){
		for(int k=1;k<i;k++){
			if (list[k]==n)
				return k;
			if (list[k]>n){
				//System.out.println(""+n+list[--k]);
				return n-list[k];
			}

		}
		return 0;
	}

	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		long n= in.nextLong();
		long[] list = new long[(int)Math.pow(10,7)];
		int i=1;
		long j=0;
		while (j<=n){
			j=i*(i+1)/2;
			list[i++]=j;
		}

		//System.out.println(Arrays.toString(list));

		System.out.println(infinite(n,i,list));
	}
}

import java.util.Scanner;

/**
 *
 * @author AdminHP-262
 */
public class InfiniteSequence {

    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);

        long n = scanner.nextLong();

        long curr = 1;
        long sum = 0, oldSum = 0;
        for (long i = 1; i <= 100000000; i++) {

            sum += i;

            if (sum == n) {
                System.out.println(i);
                return;
            }
            if (sum > n) {
                System.out.println((sum - (i - 1)) % oldSum);
                return;
            }
            oldSum = sum;
            curr++;
        }
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Scanner;

public class Main {

	private static Scanner scanner = new Scanner(System.in);

	private static StreamTokenizer inputReader = new StreamTokenizer(
			new BufferedReader(new InputStreamReader(System.in)));

	public static int nextInt() {
		int a = -1;
		try {
			inputReader.nextToken();
			a = (int) inputReader.nval;
		} catch (Exception e) {
		}
		return a;
	}

	public static void main(String[] args) {
		long n = scanner.nextLong();
		long s2 = (long) Math.sqrt(2 * n);
		long s1 = s2 - 1;
		long s3 = s2 + 1;

		long p1 = (s1 + 1) * s1 / 2;
		long p2 = (s2 + 1) * s2 / 2;
		long p3 = (s3 + 1) * s3 / 2;

		if (n > p3) {
			System.out.println(p3 - n);
		} if (n > p2 && n < p3) {
			System.out.println(n - p2);
		} if (n < p2) {
			System.out.println(n - p1);
		}

	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Scanner;

public class Main {

	private static Scanner scanner = new Scanner(System.in);

	private static StreamTokenizer inputReader = new StreamTokenizer(
			new BufferedReader(new InputStreamReader(System.in)));

	public static int nextInt() {
		int a = -1;
		try {
			inputReader.nextToken();
			a = (int) inputReader.nval;
		} catch (Exception e) {
		}
		return a;
	}

	public static void main(String[] args) {
		long n = scanner.nextLong();
		long s2 = (long) Math.sqrt(2 * n);
		long s1 = s2 - 1;
		long s3 = s2 + 1;

		long p1 = (s1 + 1) * s1 / 2;
		long p2 = (s2 + 1) * s2 / 2;
		long p3 = (s3 + 1) * s3 / 2;

		if (n > p3) {
			System.out.print(p3 - n);
		} if (n > p2 && n < p3) {
			System.out.print(n - p2);
		} if (n < p2) {
			System.out.print(n - p1);
		}

	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Scanner;

public class Main {

	private static Scanner scanner = new Scanner(System.in);

	private static StreamTokenizer inputReader = new StreamTokenizer(
			new BufferedReader(new InputStreamReader(System.in)));

	public static int nextInt() {
		int a = -1;
		try {
			inputReader.nextToken();
			a = (int) inputReader.nval;
		} catch (Exception e) {
		}
		return a;
	}

	public static void main(String[] args) {
		long n = scanner.nextLong();
		long s2 = (long) Math.sqrt(2 * n);
		long s1 = s2 - 1;
		long s3 = s2 + 1;

		long p1 = (s1 + 1) * s1 / 2;
		long p2 = (s2 + 1) * s2 / 2;
		long p3 = (s3 + 1) * s3 / 2;

		long leftRangeStart = (s1 - 2) * (s1 - 1) / 2;
		long leftRangeEnd = leftRangeStart + s1;

		long middleRangeStart = (s1 + 1) * s1 / 2;
		long middleRangeEnd = middleRangeStart + s2;

		long rightRangeStart = (s2 + 1) * s2 / 2;
		long rightRangeEnd = rightRangeStart + s3;

		if (n >= leftRangeStart && n <= leftRangeEnd) {
			System.out.print(n - leftRangeStart);
			return;
		}

		if (n >= middleRangeStart && n <= middleRangeEnd) {
			System.out.print(n - middleRangeStart);
			return;
		}

		if (n >= rightRangeStart && n <= rightRangeEnd) {
			System.out.print(n - rightRangeStart);
			return;
		}

	}

}

//package main;

import java.io.*;
import java.util.*;
import java.awt.Point;
import java.math.BigInteger;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    void run() throws Exception {
        long n = nl();
        TreeSet<Long> set = new TreeSet<>();
        for(int i=1; i<100; i++) {
            long num = i * (i + 1) / 2;
            set.add(num);
        }
        //pl(set);

        pl(n - set.lower(n));
    }

    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

    int ni() throws Exception {
        return Integer.parseInt(nextToken());
    }

    long nl() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nd() throws Exception {
        return Double.parseDouble(nextToken());
    }

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            long n = in.nextLong();
            long low = 0;
            long high = 1818000;
            while (high - low > 1)
            {
                long mid = low + (high - low) / 2;
                long last = mid * (mid + 1);
                last /= 2;
                if (last <= n)
                {
                    low = mid;
                } else
                {
                    high = mid;
                }
            }
            long last = low * (low + 1);
            last /= 2;
            if (last == n)
            {
                out.println(low);
                return;
            }
            out.println(n - last);
        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

        public String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                String s = null;
                try
                {
                    s = br.readLine();
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main{

		 public static void main(String[] args) throws IOException {
			 	PrintWriter out = new PrintWriter(System.out);
				MyScanner sc = new MyScanner();
				Main solver = new Main();
				solver.solve(out, sc);
				out.flush();
				out.close();

		 }

		void solve(PrintWriter out, MyScanner sc) throws IOException{

				long n = sc.nextLong();
				long k = 0;
				while(k <= (int)1e7) {
					if(k * (k + 1) / 2 >= n ) break;
					++k;
				}

				long l = k * (k - 1) / 2;
				out.print(n - l);

		}
		static class MyScanner {
		    BufferedReader br;
		    StringTokenizer st;

		    public MyScanner() {
		       br = new BufferedReader(new InputStreamReader(System.in));
		    }

		    String next() {
		        while (st == null || !st.hasMoreElements()) {
		            try {
		                st = new StringTokenizer(br.readLine());
		            } catch (IOException e) {
		                e.printStackTrace();
		            }
		        }
		        return st.nextToken();
		    }

		    int nextInt() { return Integer.parseInt(next());}

		    long nextLong() {return Long.parseLong(next());}

		    double nextDouble() {return Double.parseDouble(next());}

		    String nextLine(){
		        String str = "";
			  try {
			     str = br.readLine();
			  } catch (IOException e) {
			     e.printStackTrace();
			  }
			  return str;
		    }

		}

}

import java.util.*;
public class main {
    public static void main(String[] args) {
        long n;
        Scanner sc=new Scanner(System.in);
        n=sc.nextLong();
        for(long i=1;;i++){
            n-=i;
            if(n<=0){
                System.out.print(i);
                break;
            }
        }
    }
}

import javafx.util.Pair;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

import javax.swing.plaf.synth.SynthTabbedPaneUI;
import javax.swing.text.html.HTMLDocument;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

/**
 * Created by LOKESH on 15-12-2017.
 */
public class graphs {

    public static void main(String args[]) throws Exception {

        InputReader in = new InputReader(System.in);
        PrintWriter out  = new PrintWriter(System.out);
        long n = in.nextInt();
        long prev = 0;
        long i = 1;
        for(i = 1; i<n ; i++){
            long s = i*(i+1)/2;
            if(s>=n){
                out.println(n-prev);
                out.flush();
                out.close();
                break;
            }
//            else if(s==n){
//                out.println(i);
//            }
            else{
                prev = s;
            }
        }
        if(n==1){
            out.println("1");
        }
        if(n==2){
            out.println("2");
        }
        out.flush();
        out.close();
    }
//-------------------------------------------------------------------------------//
    // nth fibonacci no. in logn time

    public static int fib(int n){
        int F[][] = new int[][]{{1,1},{1,0}};
        if(n==0){
            return 0;
        }
        power(F,n-1);
        return F[0][1];
    }
    public static void power(int F[][],int n){
        int M[][] = {{1,1},{1,0}};
        if(n==0 || n==1){
            return;
        }
        power(F,n/2);
        multiply(F,F);

        if(n%2!=0){
            multiply(F,M);
        }
    }
    public static void multiply(int F[][],int M[][]){
        int x =  F[0][0]*M[0][0] + F[0][1]*M[1][0];
        int y =  F[0][0]*M[0][1] + F[0][1]*M[1][1];
        int z =  F[1][0]*M[0][0] + F[1][1]*M[1][0];
        int w =  F[1][0]*M[0][1] + F[1][1]*M[1][1];

        F[0][0] = x;
        F[0][1] = y;
        F[1][0] = z;
        F[1][1] = w;
    }
//---------------------------------------------------------------------------------//
////--------------------------------------------------------------------------------------///////

    public static long modPow(long base, long exp, long mod) {
        base = base % mod;
        long result =1;
        while(exp > 0)
        {
            if(exp % 2== 1)
            {
                result = (result * base) % mod;
                exp --;
            }
            else
            {
                base = (base * base) % mod;
                exp = exp >> 1;
            }

        }
        return result;
    }

//    public static long dfs(ArrayList a[] ,int head, int visited[],long node[]){
//        visited[head]=1;
//        node[head] = 1;
//        for(int i=0;i<a[head].size();i++){
//            Integer lk = (int)(long) a[head].get(i);
//            if(visited[lk]!=1){
//                visited[lk]=1;
//                //System.out.println(head+" S "+count);
//                dfs(a, lk,visited, node);
//                node[head]+=node[lk];
//                //System.out.println(head+" R "+count);
//                //return count;
//            }
//            //return count;
//
//        }
//
//        //System.out.println(head+" R2 "+count);
//        count++;
//        return count;
//    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    static class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int snext() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public String readString() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}

import javafx.util.Pair;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

import javax.swing.plaf.synth.SynthTabbedPaneUI;
import javax.swing.text.html.HTMLDocument;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

/**
 * Created by LOKESH on 15-12-2017.
 */
public class graphs {

    public static void main(String args[]) throws Exception {

        InputReader in = new InputReader(System.in);
        PrintWriter out  = new PrintWriter(System.out);
        long n = in.nextLong();
        long prev = 0;
        long i = 1;
        for(i = 1; i<n ; i++){
            long s = i*(i+1)/2;
            if(s>=n){
                out.println(n-prev+" "+s+" "+prev+" "+n);

                out.flush();
                out.close();
                break;
            }
//            else if(s==n){
//                out.println(i);
//            }
            else{
                prev = s;
            }
        }
        if(n==1){
            out.println("1");
        }
        if(n==2){
            out.println("2");
        }
        out.flush();
        out.close();
    }
//-------------------------------------------------------------------------------//
    // nth fibonacci no. in logn time

    public static int fib(int n){
        int F[][] = new int[][]{{1,1},{1,0}};
        if(n==0){
            return 0;
        }
        power(F,n-1);
        return F[0][1];
    }
    public static void power(int F[][],int n){
        int M[][] = {{1,1},{1,0}};
        if(n==0 || n==1){
            return;
        }
        power(F,n/2);
        multiply(F,F);

        if(n%2!=0){
            multiply(F,M);
        }
    }
    public static void multiply(int F[][],int M[][]){
        int x =  F[0][0]*M[0][0] + F[0][1]*M[1][0];
        int y =  F[0][0]*M[0][1] + F[0][1]*M[1][1];
        int z =  F[1][0]*M[0][0] + F[1][1]*M[1][0];
        int w =  F[1][0]*M[0][1] + F[1][1]*M[1][1];

        F[0][0] = x;
        F[0][1] = y;
        F[1][0] = z;
        F[1][1] = w;
    }
//---------------------------------------------------------------------------------//
////--------------------------------------------------------------------------------------///////

    public static long modPow(long base, long exp, long mod) {
        base = base % mod;
        long result =1;
        while(exp > 0)
        {
            if(exp % 2== 1)
            {
                result = (result * base) % mod;
                exp --;
            }
            else
            {
                base = (base * base) % mod;
                exp = exp >> 1;
            }

        }
        return result;
    }

//    public static long dfs(ArrayList a[] ,int head, int visited[],long node[]){
//        visited[head]=1;
//        node[head] = 1;
//        for(int i=0;i<a[head].size();i++){
//            Integer lk = (int)(long) a[head].get(i);
//            if(visited[lk]!=1){
//                visited[lk]=1;
//                //System.out.println(head+" S "+count);
//                dfs(a, lk,visited, node);
//                node[head]+=node[lk];
//                //System.out.println(head+" R "+count);
//                //return count;
//            }
//            //return count;
//
//        }
//
//        //System.out.println(head+" R2 "+count);
//        count++;
//        return count;
//    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    static class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int snext() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public String readString() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}

import javafx.util.Pair;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

import javax.swing.plaf.synth.SynthTabbedPaneUI;
import javax.swing.text.html.HTMLDocument;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

/**
 * Created by LOKESH on 15-12-2017.
 */
public class graphs {

    public static void main(String args[]) throws Exception {

        InputReader in = new InputReader(System.in);
        PrintWriter out  = new PrintWriter(System.out);
        long n = in.nextLong();
        long prev = 0;
        long i = 1;
        for(i = 1; i<n ; i++){
            long s = i*(i+1)/2;
            if(s>=n){
                out.println(n-prev);

                out.flush();
                out.close();
                break;
            }
//            else if(s==n){
//                out.println(i);
//            }
            else{
                prev = s;
            }
        }
        if(n==1){
            out.println("1");
        }
        if(n==2){
            out.println("2");
        }
        out.flush();
        out.close();
    }
//-------------------------------------------------------------------------------//
    // nth fibonacci no. in logn time

    public static int fib(int n){
        int F[][] = new int[][]{{1,1},{1,0}};
        if(n==0){
            return 0;
        }
        power(F,n-1);
        return F[0][1];
    }
    public static void power(int F[][],int n){
        int M[][] = {{1,1},{1,0}};
        if(n==0 || n==1){
            return;
        }
        power(F,n/2);
        multiply(F,F);

        if(n%2!=0){
            multiply(F,M);
        }
    }
    public static void multiply(int F[][],int M[][]){
        int x =  F[0][0]*M[0][0] + F[0][1]*M[1][0];
        int y =  F[0][0]*M[0][1] + F[0][1]*M[1][1];
        int z =  F[1][0]*M[0][0] + F[1][1]*M[1][0];
        int w =  F[1][0]*M[0][1] + F[1][1]*M[1][1];

        F[0][0] = x;
        F[0][1] = y;
        F[1][0] = z;
        F[1][1] = w;
    }
//---------------------------------------------------------------------------------//
////--------------------------------------------------------------------------------------///////

    public static long modPow(long base, long exp, long mod) {
        base = base % mod;
        long result =1;
        while(exp > 0)
        {
            if(exp % 2== 1)
            {
                result = (result * base) % mod;
                exp --;
            }
            else
            {
                base = (base * base) % mod;
                exp = exp >> 1;
            }

        }
        return result;
    }

//    public static long dfs(ArrayList a[] ,int head, int visited[],long node[]){
//        visited[head]=1;
//        node[head] = 1;
//        for(int i=0;i<a[head].size();i++){
//            Integer lk = (int)(long) a[head].get(i);
//            if(visited[lk]!=1){
//                visited[lk]=1;
//                //System.out.println(head+" S "+count);
//                dfs(a, lk,visited, node);
//                node[head]+=node[lk];
//                //System.out.println(head+" R "+count);
//                //return count;
//            }
//            //return count;
//
//        }
//
//        //System.out.println(head+" R2 "+count);
//        count++;
//        return count;
//    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    static class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int snext() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public String readString() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}

import java.util.*;
import java.math.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner cin = new Scanner(System.in);
		long tmp = cin.nextLong();
		long lo = 1, hi = tmp, res = 0;
		while(lo <= hi)
		{
			long mid = (lo + hi) / 2;
			if(mid * (mid + 1) / 2 >= tmp)
				hi = mid - 1;
			else
			{
				lo = mid + 1;
				res = Math.max(res, mid);
			}
		}
		long ans = tmp - res * (res + 1) / 2;
		System.out.println(ans);
		cin.close();
	}
}

import java.io.*;
import java.util.*;
/**
 *
 * @author Aaryan
 * AV
 */
public class Test {
    public static void main(String[] args) throws Exception {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        long n = Integer.parseInt(br.readLine());
        long res=0;
        for(long i=1; i<=Math.sqrt(2*n); i++){
            long t = (long)(Math.pow(i, 2)+i)/2;
            if(t==n){
                res = (i);
                break;

            }
            else{
                res = (n-t);

            }
        }
        out.println(res);
        out.flush();

            }
    }

import java.io.*;
import java.util.*;
/**
 *
 * @author Aaryan
 * AV
 */
public class Test {
    public static void main(String[] args) throws Exception {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        long n = Long.parseLong(br.readLine());
        long res=0;

        for(long i=1; i<=Math.sqrt(2*n); i++){
            long t = (long)(Math.pow(i, 2)+i)/2;

            if(t>=n){
                out.println(i-(t-n));
                out.flush();
                break;
            }

        }
    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main implements Runnable  {
    private void solve() throws IOException {
      long n=nextLong();
      long curr=1;
      while(n>curr){
      n-=curr;
      writer.println(n);
      curr++;
      }
      writer.println(n);
    }

    public static void main(String[] args) {
        new Main().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;

public class tmp1 {

    private static Reader in;
    private static PrintWriter out;

    public static void main(String[] args) throws IOException {

        in = new Reader();
        out = new PrintWriter (System.out, true);

        long ans[] = new long[100];
        ans[1] = 1;
        for (int i = 2; i < ans.length; i++) {
            ans[i] = ans[i-1] + i;
        }
        //out.println(Arrays.toString(ans));
        long n = in.nextLong();
        int idx = Arrays.binarySearch(ans, n);
        //out.println(idx);
        if (idx < 0)
            idx = -idx - 2;
        else
            idx--;
        out.println(n-ans[idx]);
        out.close();
        in.close();
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;
        public Reader(){
            din=new DataInputStream(System.in);
            buffer=new byte[BUFFER_SIZE];
            bufferPointer=bytesRead=0;
        }

        public Reader(String file_name) throws IOException{
            din=new DataInputStream(new FileInputStream(file_name));
            buffer=new byte[BUFFER_SIZE];
            bufferPointer=bytesRead=0;
        }

        public String readLine() throws IOException{
            byte[] buf=new byte[64]; // line length
            int cnt=0,c;
            while((c=read())!=-1){
                if(c=='\n')break;
                buf[cnt++]=(byte)c;
            }
            return new String(buf,0,cnt);
        }

        public int nextInt() throws IOException{
            int ret=0;byte c=read();
            while(c<=' ')c=read();
            boolean neg=(c=='-');
            if(neg)c=read();
            do{ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');
            if(neg)return -ret;
            return ret;
        }

        public long nextLong() throws IOException{
            long ret=0;byte c=read();
            while(c<=' ')c=read();
            boolean neg=(c=='-');
            if(neg)c=read();
            do{ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');
            if(neg)return -ret;
            return ret;
        }

        public double nextDouble() throws IOException{
            double ret=0,div=1;byte c=read();
            while(c<=' ')c=read();
            boolean neg=(c=='-');
            if(neg)c = read();
            do {ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');
            if(c=='.')while((c=read())>='0'&&c<='9')
                ret+=(c-'0')/(div*=10);
            if(neg)return -ret;
            return ret;
        }

        public char nextChar() throws IOException{
            byte c=read();
            while(c<=' ')c=read();
            return (char)c;
        }

        private void fillBuffer() throws IOException{
            bytesRead=din.read(buffer,bufferPointer=0,BUFFER_SIZE);
            if(bytesRead==-1)buffer[0]=-1;
        }

        private byte read() throws IOException{
            if(bufferPointer==bytesRead)fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException{
            if(din==null) return;
            din.close();
        }
    }
}

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;

public class tmp1 {

    private static Reader in;
    private static PrintWriter out;

    public static void main(String[] args) throws IOException {

        in = new Reader();
        out = new PrintWriter (System.out, true);

        long ans[] = new long[100000];
        ans[1] = 1;
        for (int i = 2; i < ans.length; i++) {
            ans[i] = ans[i-1] + i;
        }
        //out.println(Arrays.toString(ans));
        long n = in.nextLong();
        int idx = Arrays.binarySearch(ans, n);
        //out.println(idx);
        if (idx < 0)
            idx = -idx - 2;
        else
            idx--;
        out.println(n-ans[idx]);
        out.close();
        in.close();
    }

    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;
        public Reader(){
            din=new DataInputStream(System.in);
            buffer=new byte[BUFFER_SIZE];
            bufferPointer=bytesRead=0;
        }

        public Reader(String file_name) throws IOException{
            din=new DataInputStream(new FileInputStream(file_name));
            buffer=new byte[BUFFER_SIZE];
            bufferPointer=bytesRead=0;
        }

        public String readLine() throws IOException{
            byte[] buf=new byte[64]; // line length
            int cnt=0,c;
            while((c=read())!=-1){
                if(c=='\n')break;
                buf[cnt++]=(byte)c;
            }
            return new String(buf,0,cnt);
        }

        public int nextInt() throws IOException{
            int ret=0;byte c=read();
            while(c<=' ')c=read();
            boolean neg=(c=='-');
            if(neg)c=read();
            do{ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');
            if(neg)return -ret;
            return ret;
        }

        public long nextLong() throws IOException{
            long ret=0;byte c=read();
            while(c<=' ')c=read();
            boolean neg=(c=='-');
            if(neg)c=read();
            do{ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');
            if(neg)return -ret;
            return ret;
        }

        public double nextDouble() throws IOException{
            double ret=0,div=1;byte c=read();
            while(c<=' ')c=read();
            boolean neg=(c=='-');
            if(neg)c = read();
            do {ret=ret*10+c-'0';}while((c=read())>='0'&&c<='9');
            if(c=='.')while((c=read())>='0'&&c<='9')
                ret+=(c-'0')/(div*=10);
            if(neg)return -ret;
            return ret;
        }

        public char nextChar() throws IOException{
            byte c=read();
            while(c<=' ')c=read();
            return (char)c;
        }

        private void fillBuffer() throws IOException{
            bytesRead=din.read(buffer,bufferPointer=0,BUFFER_SIZE);
            if(bytesRead==-1)buffer[0]=-1;
        }

        private byte read() throws IOException{
            if(bufferPointer==bytesRead)fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException{
            if(din==null) return;
            din.close();
        }
    }
}

import java.io.*;
import java.util.*;
public class hello{
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        int  a=in.nextInt();
        int a_one=count(a);
        //System.out.println(a_one);

        if(a_one*a_one+a_one==2*a){
            System.out.println(a_one);
        }else{
           int tmp=a-a_one*a_one-a_one;
           System.out.println(tmp);
        }
    }

    public static int count(int  num){
        for(int i=0;i<num;i++){
            //System.out.println(i);
            if(i*i+i==2*num){
                return i;
            }
            if(i*i+i>2*num){
                return i-1;
            }
        }
        return 0;
    }
}

import javax.management.timer.Timer;
import java.sql.Time;
import java.util.Scanner;

/**
 * Created by xgh on 2016/2/16.
 */
public class CF{
        public static void main(String[] args){
            Scanner in=new Scanner(System.in);
            long  a=in.nextLong();
            //long a=1000000000000L;
            long a_one=count(a);

            //System.out.println(a_one);

            if(a_one*a_one+a_one==2*a){
                System.out.println(a_one);
            }else{
                long tmp=(long)a-(a_one*a_one+a_one)/2;
                System.out.println(tmp);
            }
            return;
        }

        public static long count(long  num) {
            long num_two = 2 * num;
            long i = (long) Math.sqrt(num_two) - 1;
            //System.out.println(i);
            if (i < 0) {
                i = 0;
            }
            for (; i < num; i++) {
                //System.out.println(i);
                if (i * i + i == num_two) {
                    return i;
                }
                if (i * i + i > num_two) {
                    return i - 1;
                }
            }
            return 0;
        }
}

import java.util.Scanner;

public class test9 {
public static void main(String args[])
{
	Scanner s = new Scanner(System.in);
	long n = s.nextLong();
	for(long i = 1;i<=n;i++)
	{
		n -= i;
	}
	System.out.println(n + 1);
}
}

import java.util.Scanner;

public class Educational7A {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double n=sc.nextDouble();
		int t=0;
		t=(int) Math.sqrt(2*n+1);
		if(!(t*(t-1)/2<=n&&(t+1)*t/2>=n))
			t+=1;
		int ans=	(int) (n-(t-1)*t/2);
		System.out.println(ans);
	}
}

import java.util.*;

public class A{
    public static void main( String[] args){
        Scanner in = new Scanner(System.in);
        int n  = in.nextInt();
        System.out.println((int)((-1 + Math.sqrt(1+8*n))/2));
    }
}

import java.io.*;
import java.util.StringTokenizer;

/**
 * Created by grzegorz on 10.04.16.
 */
public class InfinitySequence {
    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer tokenizer = new StringTokenizer("");

    public static String nextString() throws IOException {
        while(!tokenizer.hasMoreTokens()){
            tokenizer = new StringTokenizer(in.readLine());
        }
        return tokenizer.nextToken();
    }

    public static int nextInt() throws IOException {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws IOException {
        return Long.parseLong(nextString());
    }

    public static void solve() throws IOException {
        long n = 10;
        long p = (long)Math.sqrt(2*n)+1;
        long res = n - (p-1)*p/2;
        if(res <= 0) {
            p = p-1;
            res = n - (p-1)*p/2;
        }
        out.print(res);
    }

    public static void main(String[] args) throws IOException {
        solve();
        out.close();
        in.close();
    }

}

import java.io.*;
import java.util.StringTokenizer;

/**
 * Created by grzegorz on 10.04.16.
 */
public class InfinitySequence {
    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer tokenizer = new StringTokenizer("");

    public static String nextString() throws IOException {
        while(!tokenizer.hasMoreTokens()){
            tokenizer = new StringTokenizer(in.readLine());
        }
        return tokenizer.nextToken();
    }

    public static int nextInt() throws IOException {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws IOException {
        return Long.parseLong(nextString());
    }

    public static void solve() throws IOException {
        long n = nextLong();
        long p = (long)Math.sqrt(2*n);
        long res = n - (p-1)*p/2;
        out.print(res);
    }

    public static void main(String[] args) throws IOException {
        solve();
        out.close();
        in.close();
    }

}

import java.util.*;
public class force1 {
	public static void main(String args[])
	{
		int i=1;
		long sum=0;
		Scanner sc=new Scanner(System.in);
		long num=sc.nextLong();
		while((i*(i+1))/2 <= num)
			i++;
		i=i-1;
		if((i*(i+1))/2 == num)
		{
			System.out.println(i);
		}
		else
		{
		System.out.println(i);
		for(long j=((i*i+i)/2)+1;j<=num;j++)
		{
			sum=sum+1;
		}
		System.out.println(sum);
		}
		sc.close();
	}

}

import java.util.*;

public class Main {
    public static void main(String args[])
    {
        long n = new Scanner(System.in).nextLong();
        long i = 1;
        for(;((i+1) * (i+2))/2 < n; i ++);
        n -= (i * (i +  1)) / 2;
        System.out.println(n);
    }
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author sarthak
 */

import java.util.*;
import java.math.*;
import java.io.*;

public class eduRnd7_A {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return "";
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
static class P implements Comparable{

        private int x, y;

        public P(int x, int y) {
            this.x = x;
            this.y = y;
        }

        public int hashCode() {
            return (x * 31) ^ y;
        }

        public boolean equals(Object o) {
            if (o instanceof P) {
                P other = (P) o;
                return (x == other.x && y == other.y);
            }
            return false;
        }
        public int compareTo(Object obj) {
		P l = (P) obj;
		if (this.x == l.x){
			if (this.y == l.y) return 0;
			return (this.y < l.y)? -1: 1;
		}
		return (this.x < l.x)? -1: 1;
	}
    }

    public static void main(String[] args){

    FastScanner s = new FastScanner(System.in);

    long n=s.nextLong();
    long k=(long)Math.floor((Math.sqrt(1+8*n)-1)/2);
   // System.out.println(k);
    n=n-k*(k+1)/2;
    long e=0;
    while(n!=0){
        n--;e++;
    }
    System.out.println(e);

    StringBuilder op=new StringBuilder();
    }

}

/*
 * CSE 2013, NIT SILCHAR
 */
//package EducationalRound7;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author Nikhil Pathania
 */
public class A {
     public static void main(String args[]) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        long n=Long.parseLong(br.readLine());
        long x=n*2;
        long index=0;
        int max=Integer.MAX_VALUE;
        long ans=0;
        for(int i=1;i<max;i++)
        {
           if(i*(i+1)>x)
           {
               index=i-1;
               break;
           }
        }

        if(ans==n)
        {
        System.out.println(index);
        }
        else
        {
            ans=index*(index-1)/2;
            index=n-ans;
            System.out.println(index);
        }
    }
}

import java.util.Scanner;

public class TheTime {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long pos = sc.nextLong();
		if(pos == 1)
		{
			System.out.println(1);
			return;
		}
		long k = 1;

		while(true)
		{
			long res = (k*k-1)/2;
			if(res > pos)
			{
				k --;
				break;
			}
			if(res == pos)
			{
				break;
			}

			k++;
		}
//		System.out.println(k);
		long past = (k*(k-1))/2;
//		System.out.println(past);
		System.out.println(pos - past );
	}

}

import java.util.Scanner;

public class TheTime {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long pos = sc.nextLong();
		long k = 1;

		while(true)
		{
			long res = (k*k-1)/2;
			if(res > pos)
			{
				k --;
				break;
			}
			if(res == pos)
			{
				break;
			}

			k++;
		}
//		System.out.println(k);
		long past = (k*(k-1))/2;
//		System.out.println(past);
		System.out.println(pos - past );
	}

}

import java.util.*;

public class me
{
	public static void main(String[] args)
	{
	    Scanner br=new Scanner(System.in);
	    long n=br.nextLong();
	    long s=0;
	    for(long i=1;i<100;i++)
	    {
	        for(long j=1;j<=i;j++)
	        {
	            s++;
	            // System.out.println(j);
	            if(s==n){
	            System.out.println(j);
	            break;
	        }
	    }
	    }
	}
}

import java.util.*;
public class marte{

private int contor=0;

public static void main (String args[]) {

Scanner input=new Scanner(System.in);

HashMap<String, Integer> map= new HashMap<String, Integer>();
HashMap<Integer, Integer> start= new HashMap<Integer, Integer>();
HashMap<Integer, Integer> finish= new HashMap<Integer, Integer>();
HashMap<Integer, Integer> maxime= new HashMap<Integer, Integer>();

			Long n=input.nextLong();

			double radical=(Math.sqrt(n*8+1)-1)/2;

		//	System.out.println("radical="+radical);

			int rad=(int)radical;

		//	System.out.println("radical="+rad);

		int baza=-1;

		if((((rad*2+1)*(rad*2+1))-1)/8==n) baza=rad;
		else baza=rad+1;

		Long part=baza*2+1L;
		part=part*part;
	//	System.out.println("part="+part);

		Long pozbaza=
		(part-1)/8L;
			//System.out.println("pozbaza="+pozbaza);

	//	System.out.println("baza="+baza);

		Long result=baza-(pozbaza-n);

		System.out.println(result);

	}

		}

import java.util.Scanner;

public class CodeForces137 {
  public static long triangulate(long a) {
    return (a * (a + 1)) / 2;
  }
  public static void main(String argv[]) {
    Scanner scanner = new Scanner(System.in);

    long size = scanner.nextLong();
    long index = 1;

    while(triangulate(index + 1) < size) {
      index++;
    }

    System.out.println(size - triangulate(index));

    scanner.close();
  }
}

import java.util.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		long seq = scan.nextLong();
		long x = 1;

        for(int i = 0; i < seq; i++){
            seq-=x;
            x++;
        }
        System.out.println(seq);
	}
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.awt.Point;

public class TryB
{

    static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int ni() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nl() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nia(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = ni();
			}
			return a;
		}

		public String rs() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

    static long mod=1000000007;
    static BigInteger bigInteger = new BigInteger("1000000007");
    static int n = (int)1e6;
    static boolean[] prime;
    static ArrayList<Integer> as;
    static void sieve() {
			Arrays.fill(prime	, true);
			prime[0] = prime[1] = false;
			for(int i = 2 ; i * i <= n ; ++i) {
				if(prime[i]) {
					for(int k = i * i; k< n ; k+=i) {
						prime[k] = false;
					}
				}
			}

		}
		static PrintWriter w = new PrintWriter(System.out);
 static char [][]sol;
    public static void main(String[] args)
    {

        InputReader sc = new InputReader(System.in);
        //PrintWriter w = new PrintWriter(System.out);

       /*
        prime  = new boolean[n + 1];
		sieve();
		prime[1] = false;
		*/
		/*
		as = new ArrayList<>();
		for(int i=2;i<=1000000;i++)
		{
		    if(prime[i])
		    as.add(i);
		}
		*/

       /*

	long a = sc.nl();

            BigInteger ans = new BigInteger("1");
            for (long i = 1; i < Math.sqrt(a); i++) {
                if (a % i == 0) {
                    if (a / i == i) {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));

                    } else {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));
                        ans = ans.multiply(BigInteger.valueOf(phi(a / i)));

                    }

                }
            }
            w.println(ans.mod(bigInteger));
            */

         // MergeSort ob = new MergeSort();
       // ob.sort(arr, 0, arr.length-1);

    // Student []st = new Student[x];
   // st[i] = new Student(i,d[i]);
     //Arrays.sort(st,(p,q)->p.diff-q.diff);
   long []a = new long[10000001];
   for(int i=1;i<=10000000;i++)
   {
       a[i] = (i*(i+1))/2;
   }
   int ans = 0;
   int f = 0;
   long x = sc.nl();
   for(int i=1;i<=10000000;i++)
   {
       if(a[i] == x)
       {
           f = 1;
           ans = i;
           break;
       }
       else if(a[i] > x)
       {
           ans = i-1;
           break;
       }
   }
   if(f==0)
       w.println(x-a[ans]);
   else
       w.println(ans);

   w.close();

    }
    static long modexp(long x,long n,long M)
{
    long power = n;
    long result=1;
    while(power>0)
    {
        if(power % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        power = power/2;
    }
    return result;
}
    static long modInverse(long A,long M)
{
    return modexp(A,M-2,M);
}

     static class Student
    {

        int first;
        int sec;
        Student(int first,int sec)
        {
            this.first = first;
            this.sec = sec;

        }

    }

    static long lcm(long a, long b)
    {
	 return (a*b)/gcd(a, b);
    }
     public static long modMultiply(long one, long two) {

		return (one % mod * two % mod) % mod;
	}
    static long fx(int m)
    {
        long re = 0;
        for(int i=1;i<=m;i++)
        {
            re += (long) (i / gcd(i,m));
        }
        return re;
    }
     static long gcd(long a, long b)
    {
	 if (a == 0)
	  return b;

	return gcd(b%a, a);
    }

     static long phi(long nx)
    {
        // Initialize result as n
        double result = nx;

        // Consider all prime factors of n and for
        // every prime factor p, multiply result
        // with (1 - 1/p)
        for (int p = 0; as.get(p) * as.get(p) <= nx; ++p)
        {
            // Check if p is a prime factor.
            if (nx % as.get(p) == 0)
            {
                // If yes, then update n and result
                while (nx % as.get(p) == 0)
                    nx /= as.get(p);
                result *= (1.0 - (1.0 / (double) as.get(p)));
            }
        }

        // If n has a prime factor greater than sqrt(n)
        // (There can be at-most one such prime factor)
        if (nx > 1)
            result *= (1.0 - (1.0 / (double) nx));

        return (long)result;

        //return(phi((long)result,k-1));

    }

    public static void primeFactors(int n,int x)
    {
        as = new ArrayList<>();

        // Print the number of 2s that divide n
        while (n%2==0)
        {

            as.add(2);
            //System.out.print(2 + " ");
            n /= 2;

        }

        // n must be odd at this point.  So we can
        // skip one element (Note i = i +2)
        for (int i = 3; i <= Math.sqrt(n); i+= 2)
        {
            // While i divides n, print i and divide n
            while (n%i == 0)
            {

               // System.out.print(i + " ");

                as.add(i);
                n /= i;

            }

        }

        // This condition is to handle the case whien
        // n is a prime number greater than 2
        if (n >= 2)
        {

            as.add(n);
        }

    }
    static int digitsum(int x)

    {

        int sum = 0;
        while(x > 0)
        {
            int temp = x % 10;
            sum += temp;
            x /= 10;
        }
        return sum;

    }
    static int countDivisors(int n)
    {
        int cnt = 0;
        for (int i = 1; i*i <=n; i++)
        {
             if (n % i == 0 && i<=1000000)
             {
                // If divisors are equal,
                // count only one
                if (n / i == i)
                   cnt++;

                else // Otherwise count both
                    cnt = cnt + 2;
             }
         }
        return cnt;
    }

    static boolean isprime(int n)
    {

    if(n == 2)
        return true;
    if(n == 3)
        return true;
    if(n % 2 == 0)
        return false;
    if(n % 3 == 0)
        return false;

    int i = 5;
   int w = 2;

    while(i * i <= n)
    {
        if(n % i == 0)
            return false;

        i += w;
        w = 6 - w;
    }

    return true;
    }

    static long log2(long value) {
    return Long.SIZE-Long.numberOfLeadingZeros(value);
}

    static int binarysearch(int []arr,int p,int n)
    {
        //ArrayList<Integer> as = new ArrayList<>();
        //as.addAll(0,at);
        //Collections.sort(as);
        boolean re = false;
        int st = 0;
        int end = n-1;
        int f = 0;
        int r = 0;

        while(st <= end)
        {
            int mid = (st + end)/2;

            if(p > arr[mid])
            {
                st = mid+1;

            }
            else if(p < arr[mid])
            {
                end = mid-1;

            }
            else
            {
                f = 1;
                r = mid;
                break;
            }

        }
        if(f==1)
            return r;
        else
         return end;

    }
    static int binarysearchgrt(int []arr,int p,int n)
    {
        //ArrayList<Integer> as = new ArrayList<>();
        //as.addAll(0,at);
        //Collections.sort(as);
        boolean re = false;
        int st = 0;
        int end = n-1;
        int f = 0;
        int r = 0;

        while(st <= end)
        {
            int mid = (st + end)/2;

            if(p > arr[mid])
            {
                st = mid+1;

            }
            else if(p < arr[mid])
            {
                end = mid-1;

            }
            else
            {
                f = 1;
                r = mid;
                break;
            }

        }
        if(f==1)
            return r;
        else
         return st;

    }

    /* Java program for Merge Sort */
static class MergeSort
{
    // Merges two subarrays of arr[].
    // First subarray is arr[l..m]
    // Second subarray is arr[m+1..r]
    void merge(int arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        int L[] = new int [n1];
        int R[] = new int [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    void sort(int arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }

    /* A utility function to print array of size n */

}

    public static int ip(String s){
		return Integer.parseInt(s);
	}
	 public static String ips(int s){
		return Integer.toString(s);
	}

}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.awt.Point;

public class TryB
{

    static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int ni() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nl() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nia(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = ni();
			}
			return a;
		}

		public String rs() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

    static long mod=1000000007;
    static BigInteger bigInteger = new BigInteger("1000000007");
    static int n = (int)1e6;
    static boolean[] prime;
    static ArrayList<Integer> as;
    static void sieve() {
			Arrays.fill(prime	, true);
			prime[0] = prime[1] = false;
			for(int i = 2 ; i * i <= n ; ++i) {
				if(prime[i]) {
					for(int k = i * i; k< n ; k+=i) {
						prime[k] = false;
					}
				}
			}

		}
		static PrintWriter w = new PrintWriter(System.out);
 static char [][]sol;
    public static void main(String[] args)
    {

        InputReader sc = new InputReader(System.in);
        //PrintWriter w = new PrintWriter(System.out);

       /*
        prime  = new boolean[n + 1];
		sieve();
		prime[1] = false;
		*/
		/*
		as = new ArrayList<>();
		for(int i=2;i<=1000000;i++)
		{
		    if(prime[i])
		    as.add(i);
		}
		*/

       /*

	long a = sc.nl();

            BigInteger ans = new BigInteger("1");
            for (long i = 1; i < Math.sqrt(a); i++) {
                if (a % i == 0) {
                    if (a / i == i) {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));

                    } else {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));
                        ans = ans.multiply(BigInteger.valueOf(phi(a / i)));

                    }

                }
            }
            w.println(ans.mod(bigInteger));
            */

         // MergeSort ob = new MergeSort();
       // ob.sort(arr, 0, arr.length-1);

    // Student []st = new Student[x];
   // st[i] = new Student(i,d[i]);
     //Arrays.sort(st,(p,q)->p.diff-q.diff);
   long []a = new long[10000001];
   for(int i=1;i<=10000000;i++)
   {
       a[i] = ((long)i*(long)(i+1))/2;
   }

   int ans = 0;
   int f = 0;
   long x = sc.nl();
   for(int i=1;i<=10000000;i++)
   {
       if(a[i] == x)
       {
           f = 1;
           ans = i;
           break;
       }
       else if(a[i] > x)
       {
           ans = i-1;
           break;
       }
   }

   if(f==0)
       w.println(x-a[ans]);
   else
       w.println(ans);

   w.close();

    }
    static long modexp(long x,long n,long M)
{
    long power = n;
    long result=1;
    while(power>0)
    {
        if(power % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        power = power/2;
    }
    return result;
}
    static long modInverse(long A,long M)
{
    return modexp(A,M-2,M);
}

     static class Student
    {

        int first;
        int sec;
        Student(int first,int sec)
        {
            this.first = first;
            this.sec = sec;

        }

    }

    static long lcm(long a, long b)
    {
	 return (a*b)/gcd(a, b);
    }
     public static long modMultiply(long one, long two) {

		return (one % mod * two % mod) % mod;
	}
    static long fx(int m)
    {
        long re = 0;
        for(int i=1;i<=m;i++)
        {
            re += (long) (i / gcd(i,m));
        }
        return re;
    }
     static long gcd(long a, long b)
    {
	 if (a == 0)
	  return b;

	return gcd(b%a, a);
    }

     static long phi(long nx)
    {
        // Initialize result as n
        double result = nx;

        // Consider all prime factors of n and for
        // every prime factor p, multiply result
        // with (1 - 1/p)
        for (int p = 0; as.get(p) * as.get(p) <= nx; ++p)
        {
            // Check if p is a prime factor.
            if (nx % as.get(p) == 0)
            {
                // If yes, then update n and result
                while (nx % as.get(p) == 0)
                    nx /= as.get(p);
                result *= (1.0 - (1.0 / (double) as.get(p)));
            }
        }

        // If n has a prime factor greater than sqrt(n)
        // (There can be at-most one such prime factor)
        if (nx > 1)
            result *= (1.0 - (1.0 / (double) nx));

        return (long)result;

        //return(phi((long)result,k-1));

    }

    public static void primeFactors(int n,int x)
    {
        as = new ArrayList<>();

        // Print the number of 2s that divide n
        while (n%2==0)
        {

            as.add(2);
            //System.out.print(2 + " ");
            n /= 2;

        }

        // n must be odd at this point.  So we can
        // skip one element (Note i = i +2)
        for (int i = 3; i <= Math.sqrt(n); i+= 2)
        {
            // While i divides n, print i and divide n
            while (n%i == 0)
            {

               // System.out.print(i + " ");

                as.add(i);
                n /= i;

            }

        }

        // This condition is to handle the case whien
        // n is a prime number greater than 2
        if (n >= 2)
        {

            as.add(n);
        }

    }
    static int digitsum(int x)

    {

        int sum = 0;
        while(x > 0)
        {
            int temp = x % 10;
            sum += temp;
            x /= 10;
        }
        return sum;

    }
    static int countDivisors(int n)
    {
        int cnt = 0;
        for (int i = 1; i*i <=n; i++)
        {
             if (n % i == 0 && i<=1000000)
             {
                // If divisors are equal,
                // count only one
                if (n / i == i)
                   cnt++;

                else // Otherwise count both
                    cnt = cnt + 2;
             }
         }
        return cnt;
    }

    static boolean isprime(int n)
    {

    if(n == 2)
        return true;
    if(n == 3)
        return true;
    if(n % 2 == 0)
        return false;
    if(n % 3 == 0)
        return false;

    int i = 5;
   int w = 2;

    while(i * i <= n)
    {
        if(n % i == 0)
            return false;

        i += w;
        w = 6 - w;
    }

    return true;
    }

    static long log2(long value) {
    return Long.SIZE-Long.numberOfLeadingZeros(value);
}

    static int binarysearch(int []arr,int p,int n)
    {
        //ArrayList<Integer> as = new ArrayList<>();
        //as.addAll(0,at);
        //Collections.sort(as);
        boolean re = false;
        int st = 0;
        int end = n-1;
        int f = 0;
        int r = 0;

        while(st <= end)
        {
            int mid = (st + end)/2;

            if(p > arr[mid])
            {
                st = mid+1;

            }
            else if(p < arr[mid])
            {
                end = mid-1;

            }
            else
            {
                f = 1;
                r = mid;
                break;
            }

        }
        if(f==1)
            return r;
        else
         return end;

    }
    static int binarysearchgrt(int []arr,int p,int n)
    {
        //ArrayList<Integer> as = new ArrayList<>();
        //as.addAll(0,at);
        //Collections.sort(as);
        boolean re = false;
        int st = 0;
        int end = n-1;
        int f = 0;
        int r = 0;

        while(st <= end)
        {
            int mid = (st + end)/2;

            if(p > arr[mid])
            {
                st = mid+1;

            }
            else if(p < arr[mid])
            {
                end = mid-1;

            }
            else
            {
                f = 1;
                r = mid;
                break;
            }

        }
        if(f==1)
            return r;
        else
         return st;

    }

    /* Java program for Merge Sort */
static class MergeSort
{
    // Merges two subarrays of arr[].
    // First subarray is arr[l..m]
    // Second subarray is arr[m+1..r]
    void merge(int arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        int L[] = new int [n1];
        int R[] = new int [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    void sort(int arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }

    /* A utility function to print array of size n */

}

    public static int ip(String s){
		return Integer.parseInt(s);
	}
	 public static String ips(int s){
		return Integer.toString(s);
	}

}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.awt.Point;

public class TryB
{

    static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int ni() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nl() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nia(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = ni();
			}
			return a;
		}

		public String rs() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

    static long mod=1000000007;
    static BigInteger bigInteger = new BigInteger("1000000007");
    static int n = (int)1e6;
    static boolean[] prime;
    static ArrayList<Integer> as;
    static void sieve() {
			Arrays.fill(prime	, true);
			prime[0] = prime[1] = false;
			for(int i = 2 ; i * i <= n ; ++i) {
				if(prime[i]) {
					for(int k = i * i; k< n ; k+=i) {
						prime[k] = false;
					}
				}
			}

		}
		static PrintWriter w = new PrintWriter(System.out);
 static char [][]sol;
    public static void main(String[] args)
    {

        InputReader sc = new InputReader(System.in);
        //PrintWriter w = new PrintWriter(System.out);

       /*
        prime  = new boolean[n + 1];
		sieve();
		prime[1] = false;
		*/
		/*
		as = new ArrayList<>();
		for(int i=2;i<=1000000;i++)
		{
		    if(prime[i])
		    as.add(i);
		}
		*/

       /*

	long a = sc.nl();

            BigInteger ans = new BigInteger("1");
            for (long i = 1; i < Math.sqrt(a); i++) {
                if (a % i == 0) {
                    if (a / i == i) {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));

                    } else {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));
                        ans = ans.multiply(BigInteger.valueOf(phi(a / i)));

                    }

                }
            }
            w.println(ans.mod(bigInteger));
            */

         // MergeSort ob = new MergeSort();
       // ob.sort(arr, 0, arr.length-1);

    // Student []st = new Student[x];
   // st[i] = new Student(i,d[i]);
     //Arrays.sort(st,(p,q)->p.diff-q.diff);
   long []a = new long[20000001];
   for(int i=1;i<=20000000;i++)
   {
       a[i] = ((long)i*(long)(i+1))/2;
   }

   int ans = 0;
   int f = 0;
   long x = sc.nl();
   for(int i=1;i<=20000000;i++)
   {
       if(a[i] == x)
       {
           f = 1;
           ans = i;
           break;
       }
       else if(a[i] > x)
       {
           ans = i-1;
           break;
       }
   }
   w.println(ans);
   w.println(f);
   w.println(a[20000000]);
   if(f==0)
       w.println(x-a[ans]);
   else
       w.println(ans);

   w.close();

    }
    static long modexp(long x,long n,long M)
{
    long power = n;
    long result=1;
    while(power>0)
    {
        if(power % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        power = power/2;
    }
    return result;
}
    static long modInverse(long A,long M)
{
    return modexp(A,M-2,M);
}

     static class Student
    {

        int first;
        int sec;
        Student(int first,int sec)
        {
            this.first = first;
            this.sec = sec;

        }

    }

    static long lcm(long a, long b)
    {
	 return (a*b)/gcd(a, b);
    }
     public static long modMultiply(long one, long two) {

		return (one % mod * two % mod) % mod;
	}
    static long fx(int m)
    {
        long re = 0;
        for(int i=1;i<=m;i++)
        {
            re += (long) (i / gcd(i,m));
        }
        return re;
    }
     static long gcd(long a, long b)
    {
	 if (a == 0)
	  return b;

	return gcd(b%a, a);
    }

     static long phi(long nx)
    {
        // Initialize result as n
        double result = nx;

        // Consider all prime factors of n and for
        // every prime factor p, multiply result
        // with (1 - 1/p)
        for (int p = 0; as.get(p) * as.get(p) <= nx; ++p)
        {
            // Check if p is a prime factor.
            if (nx % as.get(p) == 0)
            {
                // If yes, then update n and result
                while (nx % as.get(p) == 0)
                    nx /= as.get(p);
                result *= (1.0 - (1.0 / (double) as.get(p)));
            }
        }

        // If n has a prime factor greater than sqrt(n)
        // (There can be at-most one such prime factor)
        if (nx > 1)
            result *= (1.0 - (1.0 / (double) nx));

        return (long)result;

        //return(phi((long)result,k-1));

    }

    public static void primeFactors(int n,int x)
    {
        as = new ArrayList<>();

        // Print the number of 2s that divide n
        while (n%2==0)
        {

            as.add(2);
            //System.out.print(2 + " ");
            n /= 2;

        }

        // n must be odd at this point.  So we can
        // skip one element (Note i = i +2)
        for (int i = 3; i <= Math.sqrt(n); i+= 2)
        {
            // While i divides n, print i and divide n
            while (n%i == 0)
            {

               // System.out.print(i + " ");

                as.add(i);
                n /= i;

            }

        }

        // This condition is to handle the case whien
        // n is a prime number greater than 2
        if (n >= 2)
        {

            as.add(n);
        }

    }
    static int digitsum(int x)

    {

        int sum = 0;
        while(x > 0)
        {
            int temp = x % 10;
            sum += temp;
            x /= 10;
        }
        return sum;

    }
    static int countDivisors(int n)
    {
        int cnt = 0;
        for (int i = 1; i*i <=n; i++)
        {
             if (n % i == 0 && i<=1000000)
             {
                // If divisors are equal,
                // count only one
                if (n / i == i)
                   cnt++;

                else // Otherwise count both
                    cnt = cnt + 2;
             }
         }
        return cnt;
    }

    static boolean isprime(int n)
    {

    if(n == 2)
        return true;
    if(n == 3)
        return true;
    if(n % 2 == 0)
        return false;
    if(n % 3 == 0)
        return false;

    int i = 5;
   int w = 2;

    while(i * i <= n)
    {
        if(n % i == 0)
            return false;

        i += w;
        w = 6 - w;
    }

    return true;
    }

    static long log2(long value) {
    return Long.SIZE-Long.numberOfLeadingZeros(value);
}

    static int binarysearch(int []arr,int p,int n)
    {
        //ArrayList<Integer> as = new ArrayList<>();
        //as.addAll(0,at);
        //Collections.sort(as);
        boolean re = false;
        int st = 0;
        int end = n-1;
        int f = 0;
        int r = 0;

        while(st <= end)
        {
            int mid = (st + end)/2;

            if(p > arr[mid])
            {
                st = mid+1;

            }
            else if(p < arr[mid])
            {
                end = mid-1;

            }
            else
            {
                f = 1;
                r = mid;
                break;
            }

        }
        if(f==1)
            return r;
        else
         return end;

    }
    static int binarysearchgrt(int []arr,int p,int n)
    {
        //ArrayList<Integer> as = new ArrayList<>();
        //as.addAll(0,at);
        //Collections.sort(as);
        boolean re = false;
        int st = 0;
        int end = n-1;
        int f = 0;
        int r = 0;

        while(st <= end)
        {
            int mid = (st + end)/2;

            if(p > arr[mid])
            {
                st = mid+1;

            }
            else if(p < arr[mid])
            {
                end = mid-1;

            }
            else
            {
                f = 1;
                r = mid;
                break;
            }

        }
        if(f==1)
            return r;
        else
         return st;

    }

    /* Java program for Merge Sort */
static class MergeSort
{
    // Merges two subarrays of arr[].
    // First subarray is arr[l..m]
    // Second subarray is arr[m+1..r]
    void merge(int arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        int L[] = new int [n1];
        int R[] = new int [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    void sort(int arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }

    /* A utility function to print array of size n */

}

    public static int ip(String s){
		return Integer.parseInt(s);
	}
	 public static String ips(int s){
		return Integer.toString(s);
	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Nguyen Trung Hieu - vuondenthanhcong11@gmail.com
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            long count = in.readInt();

            for (long i = 0; i < 20000000; i++) {
                if (i * (i + 1) / 2 >= count) {
                    count -= i * (i - 1) / 2;
                    break;
                }
            }

            out.printLine(count);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(long i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

import java.io.*;
import java.util.*;
public class Gte
{
public static void main(String[] args)
{
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    List<Integer> a = new ArrayList<Integer>();
    for(int i = 0;i < n;i++)
    {
        for(int j = 1;j < i+2;j++)
        {
            a.add(j);
        }
    }
    System.out.println(a.get(n));
}
}

import java.util.Scanner;

public class InfiniteSequence {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n=in.nextLong();
        long r=1;
        long i=2;
        for( ; ; i++){
            r= r+i;
            if(r>=n)
                break;
        }
        while(r>n){
            i--;
            r--;
        }
        System.out.println(i);
    }

}

import java.util.*;
import java.io.*;
public class a {
	public static void main(String[] args) throws IOException {
		in.init(System.in);
		PrintWriter out = new PrintWriter(System.out);

		long n = in.nextLong();
		long hi = n;
		long lo = 0l;
		while(hi-lo>1)
		{
			long mid = (hi+lo)/2;
			long check = (mid*(mid+1))/2l;
			if(check >= n)
				hi = mid;
			if(check < n)
				lo = mid;
		}
		hi--;
		long at = (hi*(hi+1))/2;
//		System.out.println(hi+" " + lo + " "+ at);
		long ans = n - at;
		out.println(ans);
		out.close();
	}

	public static class in {
		static BufferedReader reader;
		static StringTokenizer tokenizer;

		static void init(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = new StringTokenizer("");
		}

		static String next() throws IOException {
			while (!tokenizer.hasMoreTokens()) {
				tokenizer = new StringTokenizer(reader.readLine());
			}
			return tokenizer.nextToken();
		}

		static int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		static double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		static long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}

import java.util.Scanner;

public class A {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		long x= sc.nextLong();
		long n=0L;
		long result;

		for(long i=1L; i<=x; i++){
			if((i*(i-1))/2+1>=x){
				i--;
				n= (i*(i-1))/2+1;
				break;
			}
		}
		result=x-n+1;

		System.out.println(result);
	}

}

import java.util.Scanner;

public class A {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		long x= sc.nextLong();
		long n=0L;
		long result;

		for(long i=1L; i<=x; i++){
			if((i*(i-1))/2+1>x){
				i--;
				n= (i*(i-1))/2+1;
				break;
			}
		}
		result=x-n+1;

		System.out.println(result);
	}

}

import java.util.Scanner;

public class A {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		long x= sc.nextLong();
		long n=0L;
		long result;

			long i;
		for(i=1L; i<x; i++){
			if((i*(i+1))/2>=x){
				n= (i*(i+1))/2;
				break;
			}
		}
		result=i-(n-x);

		System.out.println(result);
	}

}

import java.util.Scanner;

public class Extra2 {

	public static void main(String[] args) {
		Scanner ok = new Scanner(System.in);
		long num = ok.nextLong();

		long low = 0;
		long high = num - 1;
		long ans = 0;

		while(low <= high) {
			long mid = low + (high - low) / 2;

			if(mid * (mid + 1) / 2 < num) {
				if((mid + 1) * (mid + 2) / 2 >= num) {
					ans = mid;
					break;
				} else {
					low = mid + 1;
				}
			} else {
				high = mid - 1;
			}
		}

		long start = ans * (ans + 1) / 2;
		ans = num - start;
		System.out.println(ans);
	}
}

import java.util.Scanner;

public class Extra2 {

	public static void main(String[] args) {
		Scanner ok = new Scanner(System.in);
		long num = ok.nextLong();

		long low = 1;
		long high = (long)(2 * Math.sqrt(num));
		long ans = 0;

		while(low <= high) {
			long mid = low + (high - low) / 2;
			if(mid * (mid + 1) / 2 < num) {
				if((mid + 1) * (mid + 2) / 2 >= num) {
					ans = mid;
					break;
				} else {
					low = mid + 1;
				}
			} else {
				high = mid - 1;
			}
		}
		System.out.println(ans);
		long start = ans * (ans + 1) / 2;
		ans = num - start;
		System.out.println(ans);
	}
}

import java.util.*;
public class JavaApplication2 {
    public static void main(String args[]) {
      Scanner read = new Scanner(System.in);
      long n = read.nextLong();
      long lo = 1;
      long hi = 100000000;
      long mid = lo+(hi-lo)/2;
      long ans = 0;
      while(lo<hi){
          mid = lo+(hi-lo)/2;
          if(((mid+1)*mid)/2==n){
              ans = mid;
              break;
          }
          else if(((mid+1)*mid)/2<n){
              if(mid == lo){
                  lo++;
              }
              else{
                  lo = mid;
              }
          }
          else{
              hi = mid - 1;
          }
      }
      if((((lo+2) * lo)/2)>n){
          lo--;
      }
      if(ans!=0){
          System.out.println(ans);
      }
      else{
      if(n -(((lo+1) * lo)/2) == 0){
          System.out.println(lo);
      }
      else{
          System.out.println(n -(((lo+1) * lo)/2));
      }
      }
    }
}

import java.util.*;
public class JavaApplication2 {
    public static void main(String args[]) {
      Scanner read = new Scanner(System.in);
      long n = read.nextLong();
      long lo = 1;
      long hi = 100000000;
      long mid = lo+(hi-lo)/2;
      long ans = 0;
      while(lo<hi){
          mid = lo+(hi-lo)/2;
          if(((mid+1)*mid)/2==n){
              ans = mid;
              break;
          }
          else if(((mid+1)*mid)/2<n){
              if(mid == lo){
                  lo++;
              }
              else{
                  lo = mid;
              }
          }
          else{
              hi = mid - 1;
          }
      }
      if(ans!=0){
          System.out.println(ans);
      }
      else{
      if(n -(((lo+1) * lo)/2) == 0){
          System.out.println(lo);
      }
      else{
          System.out.println(n -(((lo+1) * lo)/2));
      }
      }
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CF_622A solver = new CF_622A();
        solver.solve(1, in, out);
        out.close();
    }

    static class CF_622A {
        public void solve(int testNumber, InputReader input, PrintWriter out) {
            FastScanner in = new FastScanner(input);
            long n = in.l();

            long bound = sqrt(n * 2);
            long left = bound * (bound + 1) / 2;
            if (left == n) {
                bound--;
                left = bound * (bound + 1) / 2;
            }
            long idx = n - left;
            out.println(idx);
        }

        long sqrt(long x) {
            long rs = (long) Math.sqrt(x);
            while (rs * rs < x)
                rs++;
            while (rs * rs > x)
                rs--;
            return rs;
        }

    }

    static class FastScanner {
        InputReader in;

        public FastScanner(InputReader in) {
            this.in = in;
        }

        public long l() {
            return in.nextLong();
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

import java.util.Scanner;

public class InfiniteSequence {

	public static void main(String... args) {

		Scanner sc = new Scanner(System.in);
		System.out.println(getNum(sc.nextLong()));
		sc.close();

	}

	public static long getNum(long n) {

		long begin = 1, end = n;

		while (begin < end) {
			long mid = (end + begin + 1) / 2;

			if (n > mid * (mid + 1) / 2) {
				begin = mid;

			} else if (n < mid * (mid + 1) / 2) {
				end = mid - 1;

			} else
				return mid;
		}

		return n - begin * (begin + 1) / 2;

	}

}

import java.util.Scanner;

public class Main {
	private static final boolean DEBUG = false ;
	private static Scanner cin = new Scanner(System.in) ;
	public static void main(String[] args) {
		long L = cin.nextLong() ;
		long n = find(L) ;
		long r = f(n) ;
		if(DEBUG) System.out.println("n = " + n + " , r = " + r);
		System.out.println(L - r);
	}
	private static long find(long L) {
		long l = 0 , r = L ;
		while(l < r){
			long mid = (l + r) / 2 ;
			long t = f(mid) ;
			if(t == L) return mid - 1 ;
			else if(t < L) l = mid + 1 ;
			else r = mid - 1 ;
			if(DEBUG) System.out.println("l =" + l + " r = " + r + " mid = " + mid);
		}
		if(f(r) < L) return r ;
		return r - 1;
	}
	private static long f(long mid) {
		if(mid % 2 == 0){
			return mid / 2 * (mid + 1) ;
		}else{
			return (mid + 1) / 2 * mid ;
		}
	}
}

import java.io.*;
import java.util.*;

public class A1008 {
    public static void main(String [] args) /*throws Exception*/ {
        InputStream inputReader = System.in;
        OutputStream outputReader = System.out;
        InputReader in = new InputReader(inputReader);//new InputReader(new FileInputStream(new File("input.txt")));new InputReader(inputReader);
        PrintWriter out = new PrintWriter(outputReader);//new PrintWriter(new FileOutputStream(new File("output.txt")));
        Algorithm solver = new Algorithm();
        solver.solve(in, out);
        out.close();
    }
}

class Algorithm {
    void solve(InputReader ir, PrintWriter pw) {

        long n = ir.nextLong();

        for (long i = 1; i <= n; i++) n -= i;

        pw.print(n);

    }

}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    String nextLine(){
        String fullLine = null;
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                fullLine = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return fullLine;
        }
        return fullLine;
    }

    String [] toArray() {
        return nextLine().split(" ");
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        InputReader inputReader = new InputReader(in);
        PrintWriter out = new PrintWriter(System.out);

        long pos = inputReader.getNextLong();
        long sol = 0;
        long left = 1;
        long right = (long)1e7;

        while(left <= right) {
            long mid = (left + right) / 2;
            long cnt = mid * (mid+1) / 2;
            if(cnt < pos) {
                sol = mid;
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }

        out.println(pos - sol * (sol+1) / 2);

        in.close();
        out.close();
    }

    public static class InputReader {

        static final String SEPARATOR = " ";

        String[] split;
        int head = 0;
        BufferedReader in;

        public InputReader(BufferedReader in) {
            this.in = in;
        }

        private void fillBuffer() throws IOException {
            if(split == null || head >= split.length) {
                head = 0;
                split = in.readLine().split(SEPARATOR);
            }
        }

        public String getNextToken() throws IOException {
            fillBuffer();
            return split[head++];

        }

        public int getNextInt() throws IOException {
            return Integer.parseInt(getNextToken());
        }

        public long getNextLong() throws IOException {
            return Long.parseLong(getNextToken());
        }
    }

}

import java.io.*;
import java.lang.reflect.Array;
import java.nio.Buffer;
import java.util.*;

public class Pair {
    public static int solve(int n){
        n--;
        for(int i=1;i<=n;i++){
            n-=i;
        }
        return (n+1);
    }

    public static void main(String[] args) throws Exception {
        try {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int count=0;
            System.out.println(solve(n));

        }
        catch (Exception e) {
        }
    }
}

import java.io.*;
import java.lang.reflect.Array;
import java.nio.Buffer;
import java.util.*;

public class Pair {

    public static void main(String[] args) throws Exception {
        try {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int count=0;
            for(int i=1;i<=n;i++){
                n-=i;
                count++;
                if(n<=0){
                    break;
                }
            }
            System.out.println(count);

        }
        catch (Exception e) {
        }
    }
}

import java.util.Scanner;

public class competitive24 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        long n= in.nextLong();
        long k=0;
        for(int i=1;i<10000000;i++){
            if(((i*(i+1))/2)<=n && (((i+1)*(i+2))/2)>n){
              if(((i*(i+1))/2)==n){
                  k=i;
                  break;
              }
              else {
                  k = (i+1)-((((i+2)*(i+1)) / 2) % n);
                  break;
              }
            }
        }
        System.out.println(k);
    }
}

import java.util.Scanner;

public class competitive24 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        long n= in.nextLong();
        long k=0;
        for(int i=1;i<10000;i++){
            if(((i*(i+1))/2)<=n && (((i+1)*(i+2))/2)>n){
              if(((i*(i+1))/2)==n){
                  k=i;
                  break;
              }
              else {
                  k = (i+1)-((((i+2)*(i+1)) / 2) % n);
                  break;
              }
            }
        }
        System.out.println(k);
    }
}

import java.util.Scanner;

public class competitive24 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        long n= in.nextLong();
        long k=0;
        for(long i=1;i<10000000;i++){
            if(((i*(i+1))/2)<=n && (((i+1)*(i+2))/2)>n){
              if(((i*(i+1))/2)==n){
                  k=i;
                  break;
              }
              else {
                  k = (i+1)-((((i+2)*(i+1)) / 2) % n);
                  break;
              }
            }
        }
        System.out.println(k);
    }
}