#include <iostream>

int main(int argc, char** argv) {

	int n, x;
	int s = 0;
	std::cin >> n >> x;
	
	int c;
	for (int i = 0; i < n; i++) {
		std::cin >> c;
		while (c < x) { x--; s++; }	
		while (c > x) { x++; s++; }
	}

	std::cout << s << std::endl;

	return 0;
}