#include <stdio.h>

f(s,p)char*s;{for(p/=8;*s;)p^=*s>>4^*s++;p^=p/4;return p%4%3;}

int main (int argc, char **argv) {

    printf("%d\n", f("0", 'e'));
    printf("%d\n", f("Foo", 'e'));
    printf("%d\n", f("Hello World!", 'o'));
    printf("%d\n", f("Alex is wrong", 'e'));
    printf("%d\n", f("Programming Puzzles and Code-Golf", 'e'));
    printf("%d\n", f("Programming Puzzles and Code-Golf", 'o'));

    return 0;
}
