Implementation of Wagner-Fischer algorithm