#include<bits/stdc++.h>
#define int long long
using namespace std;
namespace fast_IO {
#define IOSIZE 100000
char ibuf[IOSIZE], obuf[IOSIZE], *p1 = ibuf, *p2 = ibuf, *p3 = obuf;
#define getchar() ((p1==p2)and(p2=(p1=ibuf)+fread(ibuf,1,IOSIZE,stdin),p1==p2)?(EOF):(*p1++))
#define putchar(x) ((p3==obuf+IOSIZE)&&(fwrite(obuf,p3-obuf,1,stdout),p3=obuf),*p3++=x)
#define isdigit(ch) (ch>47&&ch<58)
#define isspace(ch) (ch<33)
template<typename T> inline T read() { T s = 0; int w = 1; char ch; while (ch = getchar(), !isdigit(ch) and (ch != EOF)) if (ch == '-') w = -1; if (ch == EOF) return false; while (isdigit(ch)) s = s * 10 + ch - 48, ch = getchar(); return s * w; }
template<typename T> inline bool read(T &s) { s = 0; int w = 1; char ch; while (ch = getchar(), !isdigit(ch) and (ch != EOF)) if (ch == '-') w = -1; if (ch == EOF) return false; while (isdigit(ch)) s = s * 10 + ch - 48, ch = getchar(); return s *= w, true; }
template<typename T> inline void print(T x) { if (x < 0) putchar('-'), x = -x; if (x > 9) print(x / 10); putchar(x % 10 + 48); }
inline bool read(char &s) { while (s = getchar(), isspace(s)); return true; }
inline bool read(char *s) { char ch; while (ch = getchar(), isspace(ch)); if (ch == EOF) return false; while (!isspace(ch)) *s++ = ch, ch = getchar(); *s = '\000'; return true; }
inline void print(char x) { putchar(x); }
inline void print(char *x) { while (*x) putchar(*x++); }
inline void print(const char *x) { for (int i = 0; x[i]; i++) putchar(x[i]); }
inline bool read(std::string& s) { s = ""; char ch; while (ch = getchar(), isspace(ch)); if (ch == EOF) return false; while (!isspace(ch)) s += ch, ch = getchar(); return true; }
inline void print(std::string x) { for (int i = 0, n = x.size(); i < n; i++) putchar(x[i]); }
inline bool read(bool &b) { char ch; while(ch=getchar(), isspace(ch)); b=ch^48; return true; }
inline void print(bool b) { putchar(b+48); }
template<typename T, typename... T1> inline int read(T& a, T1&... other) { return read(a) + read(other...); }
template<typename T, typename... T1> inline void print(T a, T1... other) { print(a), print(other...); }
struct Fast_IO { ~Fast_IO() { fwrite(obuf, p3 - obuf, 1, stdout); } } io;
template<typename T> Fast_IO& operator >> (Fast_IO &io, T &b) { return read(b), io; }
template<typename T> Fast_IO& operator << (Fast_IO &io, T b) { return print(b), io; }
#define cout io
#define cin io
#define endl '\n'
} using namespace fast_IO;
const int N=2e5+10;
struct node {
int time,val,pos;
int ans;
}e[N],tmp[N];
int n,m,bel[N];
int res;
namespace BIT {
int t[N];
inline int lowbit(int x){return x&-x;}
inline void update(int x,int val) {
while (x<=n) {
t[x]+=val;
x+=lowbit(x);
}
return ;
}
inline int query(int x) {
int res=0;
while (x) {
res+=t[x];
x-=lowbit(x);
}
return res;
}
}using namespace BIT;
inline void CDQ(int l,int r) {
if (l==r) return ;
int mid=l+r>>1,p=l,q=mid+1,len=0;
CDQ(l,mid),CDQ(mid+1,r);
while (p<=mid and q<=r) {
if (e[p].pos<e[q].pos) {
update(e[p].val,1);
tmp[++len]=e[p++];
}
else {
e[q].ans+=query(e[q].val);
tmp[++len]=e[q++];
}
}
while (p<=mid) {
update(e[p].val,1);
tmp[++len]=e[p++];
}
while (q<=r) {
e[q].ans+=query(e[q].val);
tmp[++len]=e[q++];
}
for (int i=l;i<=mid;i++) {
update(e[i].val,-1);
}
for (int i=l;i<=r;i++) e[i]=tmp[i-l+1];
return ;
}
inline void cdq(int l,int r) {
if (l==r) return ;
int mid=l+r>>1,p=l,q=mid+1,len=0;
cdq(l,mid),cdq(mid+1,r);
while (p<=mid and q<=r) {
if (e[p].time<e[q].time) {
update(e[p].val,1);
tmp[++len]=e[p++];
}
else {
e[q].ans+=query(1e5)-query(e[q].val);
tmp[++len]=e[q++];
}
}
while (p<=mid) {
update(e[p].val,1);
tmp[++len]=e[p++];
}
while (q<=r) {
e[q].ans+=query(1e5)-query(e[q].val);
tmp[++len]=e[q++];
}
for (int i=l;i<=mid;i++) {
update(e[i].val,-1);
}
for (int i=l;i<=r;i++) e[i]=tmp[i-l+1];
return ;
}
pair<int,int> ans[N];
int num;
signed main() {
cin>>n>>m;
for (int i=1;i<=n;i++) {
cin>>e[i].val;
e[i].pos=i,bel[e[i].val]=i;
e[i].time=m+1;
}
for (int i=1;i<=m;i++) {
int val;cin>>val;
e[bel[val]].time=i;
}
sort(e+1,e+n+1,[](node x,node y){return x.time<y.time;});
CDQ(1,n);cdq(1,n);
for (int i=1;i<=n;i++) {
if (e[i].time==m+1) continue;
ans[++num]={e[i].time,e[i].ans};
}
sort(ans+1,ans+num+1);
for (int i=1;i<=num;i++) cout<<ans[i].second<<endl;
return (0-0);
}