512
Code:

Function s($x)
Dim $j,$,$a[2*$x]
For $j = 0 to 2*$x
$a[$j] = $j-$x
Next

gosub d

For $ = 1 to $x
For $j = 1 to $
$a = c($j,$a)
gosub d
Next
$=$+($x>$)
For $j = 1 to $
$a = c(-$j,$a)
gosub d
Next
Next
If 0= $x MOD 2
$=1
gosub n
endif
For $ = 1 to $x
If $x MOD 2
gosub n
$=$+($x>$)
endif
If $ < $x
For $j = $ to $x
$a = c(-$j,$a)
gosub d
Next
endif
If 0= $x MOD 2
$=$+($x>$)
gosub n
endif
Next
$s=Split($s,a)
exit
:n
For $j = $ to $x
$a = c($j,$a)
gosub d
next
return
:d
dim $_
If $s
$s = $s + a
EndIf
For Each $_ in $a
$s= $s + SubStr("W B",1+($_=)+2*($_>),1)
next
return
EndFunction

Function c($a,$)
$c = AScan($,$a)
$[AScan($,0)]=$a
$[$c]=0
$c = $
EndFunction