The example: I need to rank for free x123456 templates and free y123456 themes, but I don't want to use two different long-tails, so can I use it like this free x123456 y123456 templates themes, having the same effect?
Yes as long as it makes sense and that the resulting keyword set occupies 2% to 5% of the total text count. Anything more than 5% and it could be spam to search engines. Anything less than 2% and it might be declared as unimportant.
I like the tool provided on http://textalyser.net because it tells you what ranking important chains of words are in, but that site does not load at this time of writing. The next site that is ok is:
On the second site, the keywords in a long-tail will be listed as "3 word phrases" and "2 word phrases".
Second question: How many long-tails keywords can I add?
In a web page itself, as many as you like.
Using phrases in the URL can help, but don't get too carried away because tests at http://try.powermapper.com/demo will turn bad if any URL exceeds a total of 78 characters.
In the title tag, I'd use caution if I were you because any title tag over 65 characters might not work too well with Bing search engine, and any tag over about 80 characters might get truncated when shown in search engine results, and it might even be truncated in title bars of maximized web browser windows.
In the description meta-tag, use caution as well as you don't want the description too long.
Whatever you do, just make sure that if you use multiple phrases on one web page, that they all relate to the web page.
For example, if you were writing a website about apples, and you had a long phrase of "red golden delicious apples", you could have another one of "bright green apples", but don't mix those phrases on the same page with "heart shaped dog biscuits" because that doesn't relate.