You can use a tikz-based solution:
Play around with the distances to achieve the desired look. I personally would shift the overline a bit to the right because of the slanting of the math font.
\documentclass{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\tikzul}[2][2pt]{
\tikz[baseline=(content.base)]{
\node(content)[inner sep=0pt]{$#2$};
\draw($(content.south west)+(#1,-1pt)$)--($(content.south east)-(#1,1pt)$);
}
}
\newcommand{\tikzol}[2][2pt]{
\tikz[baseline=(content.base)]{
\node(content)[inner sep=0pt]{$#2$};
\draw($(content.north west)+(#1,1pt)$)--($(content.north east)-(#1,-1pt)$);
}
}
\begin{document}
0: $
\tikzul[0pt]{\tikzol[0pt]{K}}*\tikzul[0pt]{\tikzol[0pt]{D}} = \tikzul[0pt]{\tikzol[0pt]{E}}$, 1:
$\tikzul[1pt]{\tikzol[1pt]{K}}*\tikzul[1pt]{\tikzol[1pt]{D}} = \tikzul[1pt]{\tikzol[1pt]{E}}$, 2:
$\tikzul{\tikzol{K}}*\tikzul{\tikzol{D}} = \tikzul{\tikzol{E}}$
\end{document}