# Python 2, 208 bytes

    w,h=input()
    def f(p,x):a,p[x]=p[x],0;a and(x%w and f(p,x-1),-~x%w and f(p,x+1),x/w and f(p,x-w),x/w>h-2or f(p,x+w))
    i=k=0
    s=1<<w*h
    exec"k+=1;p=map(int,bin(k|s)[3:]);f(p,p.index(1));i+=1-(1 in p);"*~-s
    print i