#This work is licensed under the
#Creative Commons Attribution-Share Alike 3.0 United States License.
#To view a copy of this license, visit
#http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to
#Creative Commons,
#171 Second Street, Suite 300,
#San Francisco, California, 94105, USA.

INPUT "WavPack stream";
OUTPUT "Elias gamma code as unsigned integer";
t <- read unary 0;
if t > 1 {
    p <- read (t - 1) unsigned;
    return 2 ^ (t - 1) + p;
} else {
    return t;
}
