// Base 64 encoding
import java.io.*;

public class B64Encoder extends FilterWriter {
    public B64Encoder(Writer w) { super(w); }
    private int charctr=0;
    private int linectr=0;
    private int buffer=0;
    private int encodeByte(int byt) {
	if (byt<=25) return 'A'+byt;
	if (byt<=51) return 'a'+byt-26;
	if (byt<=61) return '0'+byt-52;
	if (byt==62) return '+';
	if (byt==63) return '/';
	return -1; // huh?
    }


    public void close() throws IOException {
	flush();
	super.close();
    }

    private void writeit(int c) throws IOException {
	if (linectr++>=76) { 
	    out.write("\r\n");
	    linectr=1;
	}
	out.write(c);
    }

    public void flush() throws IOException {
	if (charctr==2) {
	    buffer<<=2; // make 16 bits to 18 bits
	    writeit(encodeByte((buffer&0x3F000)>>12));
	}
	if (charctr==1) buffer<<=4; // make 8 bits to 12 bits
	if (charctr!=0) {
	    writeit(encodeByte((buffer&0xFC0)>>6));
	    writeit(encodeByte(buffer&0x3F));
	    if (charctr==1) writeit('=');
	    writeit('=');
	}

	charctr=0;
	out.flush();
    }

    public void write(int c) throws IOException {
	int[] code = new int[3];
	int i;
	buffer<<=8;
	buffer+=c;
	if (++charctr!=3) return;
	charctr=0;
	for (i=0;i<4;i++) {
	    writeit(encodeByte((buffer&0xFC0000)>>18));
	    buffer<<=6;
	}
	buffer=0;
	return;
    }

    public void write(char[] c, int o, int l) throws IOException {
	while (l--!=0) {
	    write(c[o++]);
	}
    }

    public void write(String s, int of, int l) throws IOException {
	write(s.toCharArray(),of,l);
    }


    public static void main(String args[]) throws Exception { 
	B64Encoder filter=new B64Encoder(new OutputStreamWriter(System.out));
	int x;
	filter.write("Hello");
	do {
	    x=System.in.read();
	    if (x!=-1) filter.write(x);
	} while (x!=-1);
	filter.flush();
    }

}
