import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); MyMap exists = new MyMap(); for (int i = 0; i < n; i++) { long x = sc.nextLong(); exists.add(x); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < m; i++) { if (i > 0) { sb.append(" "); } sb.append(exists.get(sc.nextLong())); } System.out.println(sb); } static class MyMap { ArrayList list; public MyMap() { list = new ArrayList<>(); list.add(new Unit(0, 0)); list.add(new Unit(Long.MAX_VALUE, 0)); } public void add(long x) { int left = 0; int right = list.size(); while (right - left > 1) { int m = (left + right) / 2; if (list.get(m).idx >= x) { right = m; } else { left = m; } } if (list.get(right).idx == x) { list.get(right).value++; } else { list.add(right, new Unit(x, 1)); } } public int get(long x) { int left = 0; int right = list.size(); while (right - left > 1) { int m = (left + right) / 2; if (list.get(m).idx >= x) { right = m; } else { left = m; } } if (list.get(right).idx == x) { return list.get(right).value; } else { return 0; } } } static class Unit { long idx; int value; public Unit(long idx, int value) { this.idx = idx; this.value = value; } public String toString() { return idx + ":" + value; } } }