Identify the time complexity of the following code as constant, linear, quadratic, cubic, log(n), nlog(n) or NP-hard. import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main2 {

    static int mod = 1000000007;
    static FastScanner scanner;

    public static void main(String[] args) {
        scanner = new FastScanner();
        long n = scanner.nextInt();
        long k = scanner.nextInt();

        if (sum(n) == k) {
            System.out.println(0);
            return;
        }

        long s = 0;
        long e = n + 1;
        while (s < e - 1) {
            long m = (s + e) / 2;
            long put = sum(n - m);
            long candiesLeft = put - m;
            if (candiesLeft == k) {
                System.out.println(m);
                return;
            }
            if (candiesLeft > k) {
                s = m;
            } else {
                e = m;
            }
        }
    }

    static long sum(long n) {
        long last = 1 + n - 1;
        return ((1 + last) * n) / 2;
    }

    static class WithIdx {
        int val, idx;

        public WithIdx(int val, int idx) {
            this.val = val;
            this.idx = idx;
        }
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
               ... Complexity: