$$k+m=(n+m)/4+q(m,n)$$ where $q(m,n)$ is $0$, $1/4$, $1/2$, or $3/4$. $$4k+4m=n+m+4q(m,n),\quad3m=n-4k+4q(m,n),\quad m=(n-4k)/3+r(m,n)$$ where $r(m,n)=(4/3)q(m,n)$ is $0$, $1/3$, $2/3$, or $1$. So we get $$m=\lceil(n-4k)/3\rceil$$ except in the case where $q(m,n)=3/4$, in which case $m=1+((n-4k)/3)$.
There is probably a nicer way to write that, but I'm not seeing it.
EDIT (in response to the question raised in the comment):
Start with any old $m$, say, $m=0$. If $k=\lceil n/4\rceil$, you're done. If $k\lt\lceil n/4\rceil$, then add $1$ to $m$, over and over again. Each time, the left side goes up by $1$, while the right side either goes up by $1$ (one-quarter of the time) or doesn't change (three-quarters of the time). So eventually the left side will exactly equal the right side, and there's your value of $m$.
If $k\gt\lceil n/4\rceil$, then repeatedly subtract $1$ from $m$, and argue the same way.