What's the meaning of the first part of: 他爱怎么想就怎么想，我才不在乎呢 I'm not sure I understand the first part of this sentence:

他爱怎么想就怎么想，我才不在乎呢。

I found it in the Pleco C-E dictionary (Pleco is a an app on my Android) as a sample sentence for 在乎. The given translation is: “I don't care what he thinks”. Any pointers on how to understand the first part of the sentence would be welcome. Is there a general rule for X怎么Y就怎么Y? Is this some subtle usage of 就?
This would be best translated into:
He thinks however he wants to think, I don't care.

This sentence structure is often used with 什么.

如：你想吃什么就吃什么。

Word by word: You want to eat whatever, just eat whatever.

...which really means: Eat whatever you want.

This structure can work with any normal question pronoun 

(哪里/哪儿，什么，怎么，谁，什么时候，为什么。。。）. 

(wherever, whatever, however, whoever, whenever, for whatever...)

Here, 就 is pretty much equivalent to 'just', as in 'just do it'. It's not absolutely required here, but it's used very often.

You could write this type of sentence in Chinese more similarly to English:
你就吃你想吃的 (You just eat what you want to eat).

I think a native speaker would more inclined to use the xxxx什么就xxxx什么 structure, however.

See if you can wrap your head around this:

你们想去哪里玩就去哪里玩，反正我都不去了。