This you can do easily with Roles for Menu module.
This module allows you to restrict access to menu items based on user
roles. It is used when you don't want to copy your whole menu just
because for one specific role you want to hide one menu item.
- Define the user role (in your case X and Y) in your site.
- Then as per user role you can set the menu items, so the menu will be automatically gets display based on Role.
Other similar module is Menu item visibility
This module exposes configurable and extendable visibility settings
for menu links.
Both does pretty much similar activity.
Illustration for Menu item visibility module.
Steps:-
1. Module: Download and enable the module.
2. Creating User Role: Now, for example you want to set two user role X and Y. Hence, create by going at People/Permission/Roles -> add two user roles, like userX & userY as shown in following image.
3. Creating a User: Now, create two user, as shown in following image by going at People/ -> add new user, and give corresponding role which we created in step-2. You can see all specifications in the image.
4. Menu item creation: I have created a 7 Menuitems in the section Main menu by going as Structure/Menus/Main menu.
Now, during the each Menu item creation, you will find the following option at the end of page, and from there selection, FOR WHICH USER YOU WANT TO SHOW THAT MENU-ITEM. Like in follwoing case we want to show Menuitem1 to userX and userY both.
I gave the user role visibility as below, because, I want to show first 4 item to userX Role and all other to userY Role.
Item Roles Selection
Menuitem1 userX userY
Menuitem2 userX userY
Menuitem3 userX userY
Menuitem4 userX userY
Menuitem5 userY
Menuitem6 userY
Menuitem7 userY
5. Test: Now, if you Login using userXexample(which has useX role) you will see only four items, and for userYexample(which has userY role) you will see 7 items.