K-nearest neighbor algorithm. Case of handwritten numbers.