local s = io.read() local n = #s local lis = {} local ssub = "" for i = 1, 10 do lis[i] = {} for j = 1, n + 1 - i do ssub = s:sub(j, j + i - 1) if lis[i][ssub] == nil then lis[i][ssub] = 1 else lis[i][ssub] = lis[i][ssub] + 1 end end end local m = io.read("*n", "*l") local cnt = 0 local t = "" for i = 1, m do t = io.read() local tlen = #t if lis[tlen][t] then cnt = cnt + lis[tlen][t] end end print(cnt)