import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.println(NumberOf1(n));
}
public static int NumberOf1(int n){
int count = 0;
while(n!=0){
count++;
n=(n-1)&n;
}
return count;
}
}
import java.util.ArrayList;
public class Main{
int perfectDancer(int countMorning ,int countEvening,int[] morningList,int[] eveningList){
ArrayList<Integer> list1 = new ArrayList<>();
ArrayList<Integer> list2 = new ArrayList<>();
for(int i=0;i<list1.size();i++){
list1.add(morningList[i]);
}
for(int j=0;j<list2.size();j++){
list2.add(eveningList[j]);
}
return getnum(list1,list2);
}
public int getnum(ArrayList<Integer> list1,ArrayList<Integer> list2){
ArrayList<Integer> list3 ;
ArrayList<Integer> list4 ;
ArrayList<Integer> list5 ;
ArrayList<Integer> list6 ;
ArrayList<Integer> list7 =new ArrayList<>();
ArrayList<Integer> list8 =new ArrayList<>();
list3=list1;
list4=list2;
for(int i=0;i<list3.size();i++){
if(list4.contains(list3.get(i))){
list7.add(list3.get(i));
}
}
list5=list1;
list6=list2;
for(int i=0;i<list6.size();i++){
if(list5.contains(list6.get(i))){
list8.add(list6.get(i));
}
}
return list1.size()+list2.size()-list7.size()-list8.size();
}
}
public class Main5 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
ArrayList<Integer> list1 = new ArrayList<>();
ArrayList<Integer> list2 = new ArrayList<>();
for(int i=0;i<n;i++){
list1.add(sc.nextInt());
}
for(int j=0;j<m;j++){
list2.add(sc.nextInt());
}
System.out.println(getnum(list1,list2));
}
public static int getnum(ArrayList<Integer> list1,ArrayList<Integer> list2){
ArrayList<Integer> list3 ;
ArrayList<Integer> list4 ;
ArrayList<Integer> list5 ;
ArrayList<Integer> list6 ;
ArrayList<Integer> list7 =new ArrayList<>();
ArrayList<Integer> list8 =new ArrayList<>();
list3=list1;
list4=list2;
for(int i=0;i<list3.size();i++){
if(list4.contains(list3.get(i))){
list7.add(list3.get(i));
}
}
System.out.println(list7.size());
list5=list1;
list6=list2;
for(int i=0;i<list6.size();i++){
if(list5.contains(list6.get(i))){
list8.add(list6.get(i));
}
}
System.out.println(list8.size());
return list1.size()+list2.size()-list7.size()-list8.size();
}
}