/*                                             . .. ,.. .............      . I ...
                                            ......Z$O~O::~=~~==~=~:,::,.....7$D,Z........
                                            ....ZZO8Z7??77$Z$$$$$$$$+::~:=..$$O?7.I......
                                            ...D$++===I77$$$II?++===:,:+++I+$$7.:I+?+....
                                            .,7==+=++++??7II++++==~~==?II++?Z$O.Z~++?~+..
                                      ......+=++????:==+=++=~~==~~~~~~~~=+7OZ$8~Z+?7+?~+......
                                      ....~==+I?7ZZZ?=+=$?===~:,=~~~~~~~~+7?87DOZ???:+~~=.......
                                       ..~=+?$$I$II$I==?+77?~~:~.==~~~:+===+D7NOZI7IO,+~~=......
                                      ..::+$877$II8Z7=I:+?7I+,:,:.+==::,7II?N$OZZ7ZIO.=~~=......
                                ......,:,~8IIIII?OOO$=,Z=?7+?+::,,,?+.,:.?7$$OZ$OZOI7$,~~~=.....
                                .....,,.ZID:=I?I7==O$~:Z7~=?:++=,,,.?~,,,.7ZZOOD8OO7I8,~==?=....
                               ......,,O.7:~~:?I~,=?Z==~=7?7?~==~.,,=7..~:+$$Z8OZ8OZIO,::~~$,...
                               .....,:7.$$::?:I=,,::$?~,.:+~7=~===.=~7:,=:.ZOZO8D8ZO7Z+:,~=?=,..
                               ....~,I..Z+??7+?,,,,~$7::.,,~=7+~~==~===:+~.=ZOZZ88OO$$O:=:=~7=..
                               ...:,~..7?????+=~:.,,:$=~,.,,?~7I=======~?=:?ZO$$888O7$8=~:~=7+,.
                               ...:=..,ZI??7++,,..,,:~7~~..,.,:$?==~==?=I+~I88Z88OZ8$ZO?+~:~$I:....
                               .,.=...+II??8+?,,,,,,,,I7~,..,..,?I~==+I=I?~IDDOOZO7$O$OO?+~:II=+ .
                               ..~....+I?IO8$I.8N8,:,,,7=~..~IDDND8$+++=7?=7O8OO$OZ=OIO8I+~~~Z?,......
                               ..=...:+???888?D?8?8O...,7...O:88D88$$+++$I?D88OZ?7$.+7Z8I?+~:OI~=.....
                               .~....O=??8O8OO?.ZO88:..,:I,...?$$$Z$O=+7ZIIDD8OZZI...OZO???+~$=I.,....
                               .~...$Z=?7OO87O~:I~7+....,.+...+,+I?.:O=?O7D$D8OZ$?...,$O$I??=?+?~~....
                               ..,..ZZ=IOOOOZ7Z,,:=,.......:....,...:O$=ZOD$77OZI.....7OOI??+=+?~~....
                                ...ZZO?7OZOOZ?Z,,.,,.,.............,=Z7?ONNZN7ZZ......?O8I?I?=7??==...
                               ...$ZZZZ?ZZOZ$7Z=,,,,.:..............=ZO78Z8D8O7........ZO$I$?+Z?$~:+..
                               ...ZZ$ZZ~OZO,Z$IZ,,,,,,..............~?ZZ$7O+D=... .....?OZI$??ZII:~,..
                         ........OZZ7$Z$ZOI.$$I?..,,,,.............,=?Z7I7:.. ..   .....O8I7??ZI??~+~.
                         .......OZ7$7$ZZZO..+ZOI?:.,,,,:::,.......,~=7:,....      . ....8O7I??$77$~~:.
                         .......ZZ$II7ZZ?Z...$.$7.,,,,.,,,.,......,~I7......      ......8O7I??777Z~~~=
                         ......OI$??I7O$$Z...~.?I=.=.,.,.....,.,~I~~=O:.....      ......7O7II??$$I~~=,...
                         .....O$7?+?I7ZZ?~.....Z..$:.+,,,,..:7=+~~:I.?I?.....     ......,8$II?+ZZI::~=:..
                         ...,+?I==+?IO$$+.:...,:.......=IO==++=~:~:,..,=+~,..          ..ZZI$??$Z?:~~=+....
                         ...+I?===+$O$Z7................,7+===~~==?,.........         .. ,O7O??IZ?~::~:7. .
                         ...??~===$7Z$$?..............~7=I?+===~:::,.........          ...87O???ZI?::~=~....
                       ....I?~==+$O$77=..+,~++=,....~7O8=O7+==~~::,,.... ....          ...OZOI?+$77:::~:?...
                   .......+?=~~+I$OI$?=:.,,,::~=~=I$$~OZO$Z===~::..,?........            .:OO7??$7Z,,:~=I,...
                   .....~++==~7IOO77?I:,:,,,::~:?Z+=+ZO$O=Z~=:....:.,I~+.....            ..8Z$??$7Z.,,~~=$...
                    ...=?+=~7I=Z?Z7+?=:,,,,,,:~?::~+ZOZ:==Z..,==.+..=+~+?+7+...          ..=$Z??7$$..::~:?...
                   ...?I+=+7I+Z7Z7=?I....,,,,+,~~~O$$Z+~~~I:.+?~, .+,.,,...,:=.          ...7OIII$7,.::~:?I..
            .........7?++III:Z?$+~=+,.,,,,:=,,..7?I?~.....=+$$=...~,..........~.         ...IOIIIZ7~.:,~~=,:.
            ........II+777+~?7I:~~+=.~.,~.,,,.?++?+........$.:....:...........:.         ...?ZI??Z7=.:,::~~+.
            ......I7?$Z7I=I+$~::~+=,,=,.,,,,++++==..:,...........,.............,...      ...?ZII?$I=.:.,:=+~...
            ....:77O$Z7?$?$,::~~~I.=,.....:?==~..,.O8D7:.........:.............:...      ...+Z$I?Z7+.:..,~?+?...
      ........,Z7OZZZ$$I+===+,~~77:,.,.,,===:~+...NZ7+~,:++:.  .~..,..........,...       ....OZI?ZI?.:,,.:?=.Z.....
      .......$$OZO$$7++++++=,+$.7.,.,,,,+==~:+,.. ....,=::?:  ...,.,..........~....      ....$ZI?ZI?,::,,:+=~=:....
      ...,.7OZO$Z$+=++++=:IOO=,O.?.,,,,++=+=+.............. ...=.:?+,.,..+7=+=I....      ....:Z7?Z7?,~~::~+=::Z~.,.
      .,:O8OZZ?++=??++=+OOZ7,.?.,?,,,:=+++=I...........,......~:===~~,.,.7:7:=I....      .....Z$?Z7?:~~:::++~:I$...
......:7OO$I++??+??+=7ZZZO:.:=..:+++~+?+++I+.........,..,.....7:=~=~~:,,.I~7,=I....      .....ZZIZ7I~~~~::+++:,$$.,.....
....7$7II?II???+I7$OOOZZI.~:,...====????+7==.......,.. ..~....~==~::~~,,.:,.,.?....      .....I$I$7I=~~=~:++++:+Z8......
:+=?I?IIII??$OI7OZZZZZZ=+~~.....==+I????I+==~~~~~~:=,,....~..7==::,?+=........?....      .....,ZI$$$+===~:++++=.$$$.....
II?II7$ZZ$$7OZ$8$?~~=+=I?......=+=????II+=~~=~~~~~~~,......~+~~~~:+.+:.,.....,=....      ......$77$$++~==:++++==IZZZ....
ZZZZZZZ$II+:~::~~~+I?=I:......==?III?II7=~~~~~~~~~=:,,,,,~~:7==~:=..?I++==++I7=....         .  ,$7$Z++===:?+++==:7Z$Z...
++=++++==+===~~~=?$Z7,,......,:+?I??I+7?~~~~~~~~~~~::~=::,.~~=~,,...:I888D88OOI....           ..Z7$Z?+===~I?++==~+$ZOZ..
+++=++++?I77IIII$7...........=?IIII?+7??~~~~~:~~=~~~~:,...~::+:~....:8888DDZNZI....            .$I$Z??++++7?+++==:7ZZ$Z~
$$$777777777$I?I.:,.........~+?IIIII7I++~~:::::~~~~,.....:::,,......+8888DDZD8?....            ..+$Z??+++I$++++===IZ$Z$Z
777I??+=~::~?+.....      ..~+7IIII?77+==~::::,:=:,......:::,,:.. ...?8888DDZN87....            ..+$$??+++7Z+++++=+~?$$ZZ
=+++??????+II......      .+=IIIIII$7?+==~::::::,,......:,,,.~... ...+88ODDD8DD$....            ...77+????ZO+?+++==~$$7$$
=+??????IZO?.......   . ..=7IIII?+I7++=+=:::::,::.....::,,,?.... ...?88ODD88$D7....            ...+$~???+OO+?+++===~??$$
??++I$Z$ZO.,.......   ...?7IIIII?$I+?+==+:::.,,,:....,..,.+.  .. ...?8OO888888?....            ...:7:???+OZ??+++====$I77
ZZZO+.,Z:....... . .....?IIIIIII7?+++++=+:...,,,:,...,..~~ .     ...+8O8O8888O=...             ....~:???+OO7??+++===Z+.?
.....:I.....       ....?$IIIIII+I?==+++++~...,.,,,.,,.,.:...     ...=8O8OOOOO8~....             ....~???+OZZ????+~==~+$,
....O..............,.=.I$77III+7?+===++==+..,...,,.....:         ...~8O8OOOOOO~....            .....=I??+ZZO+????====I?Z
.=7,..............,=~=7777777I7I+=====+==+......,.....:~         ...:8O8OOOOOO=,...             ....+III+OZO++++++===~++
......... ......~I:==I$7777$7+??==========.,....,....,:..        ...:888OOZZOO+~...             ....+?II+OZO=+++??====+?
  .. ........:+?+=?=$8D8$ZZ$?II==========~,......,...:. .        ...:888OOZZZOI=...            .....:?I7=OZO?++?++~===?+
...   ....~=77II+I=?8OOOOZ$$??=+=~~~~~~~~~~......,.  ,.          ...=888OZZZZZI~...            ......?I7+ZZZZ?I?=++===~?
.......,+~7777+7+=?8ZDDD8Z$$7+===~~~~~~~~~~............          ...+888OZZ$Z+$+...            ......?I7=ZZZ8?7?==?=~=*/
#include<bits/stdc++.h>
using namespace std;

int n,m;
int a[50];
int k[50];
int l[50];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>k[i];
        while(k[i]--){
            cin>>a[i];
            l[a[i]]++;
        }
    }
    int cnt=0;
    for(int i=1;i<=m;i++){
        if(l[i]==n){
            cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 256