// Arup Guha
// 4/2/2026
// Solution to Program 8A: Rest Stop

import java.util.*;

public class reststop {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int numQ = stdin.nextInt();
		int highwayLen = stdin.nextInt();
		
		// Add in the beginning and end.
		TreeSet<Integer> stops  = new TreeSet<Integer>();
		stops.add(0);
		stops.add(highwayLen);
		
		// Process queries.
		for (int i=0; i<numQ; i++) {
		
			// Get query.
			int type = stdin.nextInt();
			int marker = stdin.nextInt();
		
			// Just add a stop.
			if (type == 1)
				stops.add(marker);
				
			// Query.
			else {
			
				// Find nearest markers in both directions.
				int low = stops.floor(marker);
				int high = stops.ceiling(marker);
				
				// Print min distance.
				System.out.println(Math.min(marker-low, high-marker));
			}
		}
		
	}
}