If set A has m elements and B has n elements, then there are 2mn different relations from A to B.
Since we have relation from set A to A therefore if the no of elements in set A (cardinal no ) is m then:
Total relations =2(m×m)=512
=2(m×m)=29
m2=9
m=3